C# IIS7 - 当请求参数的大小超过 30mb 时,Webrequest 失败并显示 404.13
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9310926/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
IIS7 - Webrequest failing with a 404.13 when the size of the request params exceeds 30mb
提问by John
I have a simple webmethod
我有一个简单的网络方法
[WebMethod]
public int myWebMethod(string fileName, Byte[] fileContent)
However, whenever I pass a byte array which is larger than 30mb, I get the error:
但是,每当我传递大于 30mb 的字节数组时,我都会收到错误消息:
HTTP Error 404.13 - Not Found The request filtering module is configured to deny a request that exceeds the request content length.
HTTP 错误 404.13 - Not Found 请求过滤模块被配置为拒绝超过请求内容长度的请求。
My web.config is as follows:
我的 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>
I've searched around, and the most common cause of this problem is the maxAllowedContentLengthproperty being 30mb by default. However, I have set this to be 100mb, as well as the maxRequestLengthproperty for httpRuntime.
我四处搜索,这个问题最常见的原因是maxAllowedContentLength默认情况下属性为 30mb。不过,我已经设置这是100MB,还有maxRequestLength财产httpRuntime。
I can't find a solution anywhere which isn't setting one of the properties I've already tried above. Is there something I have missed?
我无法在没有设置我上面已经尝试过的属性之一的任何地方找到解决方案。有什么我错过了吗?
回答by OnoSendai
You problem may lie in the fact that settings made in the web.configfile may be superseded by corresponding settings present in both the applicationhost.configand machine.configfiles.
您的问题可能在于web.config文件中所做的设置可能会被applicationhost.config和machine.config文件中的相应设置所取代。
If you have access to these, check if the overrideModeDefaultproperty of the corresponding sections are set to Allow, as in the following example:
如果您有权访问这些,请检查相应部分的overrideModeDefault属性是否设置为Allow,如下例所示:
machine.config
机器配置文件
<requestFiltering overrideModeDefault="Allow">
<requestLimits maxAllowedContentLength="104857600"/>
</requestFiltering>
AFAIK there is no way to override these settings if you don't have access to the corresponding configuration file.
AFAIK 如果您无权访问相应的配置文件,则无法覆盖这些设置。
You may find more information about system-wide configuration and settings override here, hereand here- and a very similar case here.
回答by Fred_W
This is pretty old. But I have the same problem today. To fix this, you need to make the necessary setting changes in web.config, then deploy to the web server. The important part is that you need to re-deploy your application to the web server. By doing so, the IIS settings are updated for you. Depending on how you do your deployment, you may need to delete your web application from the web server first, then deploy again. Updating web.config in place won't fix the problem. Hope this helps others with the same problem.
这是相当古老的。但我今天也有同样的问题。要解决此问题,您需要在 web.config 中进行必要的设置更改,然后部署到 Web 服务器。重要的部分是您需要将应用程序重新部署到 Web 服务器。这样,IIS 设置就会为您更新。根据您进行部署的方式,您可能需要先从 Web 服务器中删除您的 Web 应用程序,然后再次部署。就地更新 web.config 不会解决问题。希望这可以帮助其他有同样问题的人。

