IIS7 - 当请求参数的大小超过 30mb 时,Web 请求失败并显示 404.13

发布于 2025-01-06 22:52:31 字数 1171 浏览 0 评论 0原文

我有一个简单的 webmethod

[WebMethod]
public int myWebMethod(string fileName, Byte[] fileContent)

但是,每当我传递大于 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>

我进行了搜索,导致此问题的最常见原因是 maxAllowedContentLength 属性默认为 30mb。不过,我已将其设置为 100mb,以及 httpRuntimemaxRequestLength 属性。

我找不到任何不设置我上面已经尝试过的属性之一的解决方案。我是否错过了什么?

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:

HTTP Error 404.13 - Not Found
The request filtering module is configured to deny a request that exceeds the request content length.

My web.config is as follows:

<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 maxAllowedContentLength property being 30mb by default. However, I have set this to be 100mb, as well as the maxRequestLength property for 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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

笑红尘 2025-01-13 22:52:31

您的问题可能在于 web.config 文件中所做的设置可能会被 applicationhost.configma​​chine.config 中存在的相应设置所取代 文件。

如果您有权访问这些内容,请检查相应部分的 overrideModeDefault 属性是否设置为 Allow,如下例所示:

机器配置

<requestFiltering overrideModeDefault="Allow">
    <requestLimits maxAllowedContentLength="104857600"/>        
</requestFiltering>

据我所知,如果您无权访问相应的配置文件,则无法覆盖这些设置。

您可以在此处<找到有关系统范围配置和设置覆盖的更多信息/a>,此处此处 - 以及此处

You problem may lie in the fact that settings made in the web.config file may be superseded by corresponding settings present in both the applicationhost.config and machine.config files.

If you have access to these, check if the overrideModeDefault property of the corresponding sections are set to Allow, as in the following example:

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.

You may find more information about system-wide configuration and settings override here, here and here - and a very similar case here.

话少心凉 2025-01-13 22:52:31

这已经很老了。但我今天也有同样的问题。要解决此问题,您需要在 web.config 中进行必要的设置更改,然后部署到 Web 服务器。重要的是您需要将应用程序重新部署到 Web 服务器。这样,就会为您更新 IIS 设置。根据您的部署方式,您可能需要先从 Web 服务器中删除 Web 应用程序,然后再次部署。就地更新 web.config 并不能解决问题。希望这可以帮助其他遇到同样问题的人。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文