我有一个简单的web方法
[WebMethod]
public int myWebMethod(string fileName, Byte[] fileContent)
Run Code Online (Sandbox Code Playgroud)
但是,每当我传递一个大于30mb的字节数组时,我都会收到错误:
HTTP错误404.13 - 未找到请求筛选模块配置为拒绝超过请求内容长度的请求.
我的web.config如下:
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0"> </compilation>
<authentication mode="Windows" />
<httpRuntime useFullyQualifiedRedirectUrl="true"
maxRequestLength="102400" requestLengthDiskThreshold="102400"
/>
<pages controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID" />
</system.web>
<system.webServer>
<security>
<requestFiltering>
<requestLimits maxAllowedContentLength="104857600"/>
</requestFiltering>
</security>
</system.webServer>
</configuration>
Run Code Online (Sandbox Code Playgroud)
我一直在搜索,这个问题最常见的原因是maxAllowedContentLength默认情况下属性为30mb.但是,我已将此设置为100mb,以及maxRequestLength属性httpRuntime.
我无法在任何地方找到解决方案,而不是设置我上面已尝试过的属性之一.有没有我错过的东西?
问题可能在于,web.config文件中的设置可能会被applicationhost.config和machine.config文件中的相应设置所取代.
如果您有权访问这些,请检查相应部分的overrideModeDefault属性是否设置为Allow,如下例所示:
machine.config中
<requestFiltering overrideModeDefault="Allow">
<requestLimits maxAllowedContentLength="104857600"/>
</requestFiltering>
Run Code Online (Sandbox Code Playgroud)
如果您无权访问相应的配置文件,AFAIK无法覆盖这些设置.
您可能会发现关于全系统的配置和设置将覆盖更多的信息在这里,这里和这里 -和一个非常类似的情况在这里.