【问题标题】:IIS7 - The request filtering module is configured to deny a request that exceeds the request content lengthIIS7 - 请求过滤模块被配置为拒绝超过请求内容长度的请求
【发布时间】:2012-06-07 23:16:41
【问题描述】:

我想上传图片,它在我的机器上运行良好,但是当我将我的网站放在 IIS7 服务器上公开时,我无法上传任何东西。

错误

请求过滤模块被配置为拒绝一个请求 超过请求内容长度。

最可能的原因

在 Web 服务器上配置请求过滤以拒绝请求 因为内容长度超过了配置的值。

您可以尝试的事情

验证配置/system.webServer/security/requestFiltering/requestLimits@maxAllowedContentLength 在 applicationhost.config 或 web.config 文件中设置。

web.config 中的system.webServer

  <system.webServer>
    <validation validateIntegratedModeConfiguration="false" />
    <modules runAllManagedModulesForAllRequests="true" />
    <security>
      <requestFiltering>
         <requestLimits maxAllowedContentLength="1048576" />
      </requestFiltering>
   </security>
  </system.webServer>

如您所见,我将 maxAllowedContentLength 设置为 1gb。重新启动我的网站,仍然收到此错误。我在我的文件系统上创建了一个/uploads/ 文件夹,它也应该是。不知道是什么原因导致了这个错误以及为什么我不能上传图片。

【问题讨论】:

标签: asp.net asp.net-mvc-3 iis iis-7


【解决方案1】:
<configuration>
    <system.web>
        <httpRuntime maxRequestLength="1048576" />
    </system.web>
</configuration>

来自here

对于IIS7及以上,还需要添加以下几行:

 <system.webServer>
   <security>
      <requestFiltering>
         <requestLimits maxAllowedContentLength="1073741824" />
      </requestFiltering>
   </security>
 </system.webServer>

【讨论】:

  • 你错过了一半的故事......你还需要配置 MaxAllowedContentLength
  • @LaPuyaLoca 是正确的,这是一半的答案,我认为提供了完整的答案here
【解决方案2】:

我遇到了类似的问题,我通过更改位于“C:\Windows\System32\inetsrv\config”目录中的 applicationhost.config 文件的 requestlimits maxAllowedContentLength ="40000000" 部分解决了

寻找安全部分并添加sectionGroup。

<sectionGroup name="requestfiltering">
    <section name="requestlimits" maxAllowedContentLength ="40000000" />
</sectionGroup>

*注意删除;

<section name="requestfiltering" overrideModeDefault="Deny" />

【讨论】:

    【解决方案3】:

    以下示例 Web.config 文件将配置 IIS 以拒绝对“Content-type”标头长度大于 100 字节的 HTTP 请求的访问。

      <configuration>
       <system.webServer>
          <security>
             <requestFiltering>
                <requestLimits>
                   <headerLimits>
                      <add header="Content-type" sizeLimit="100" />
                   </headerLimits>
                </requestLimits>
             </requestFiltering>
          </security>
       </system.webServer>
    </configuration>
    

    来源:http://www.iis.net/configreference/system.webserver/security/requestfiltering/requestlimits

    【讨论】:

    • 您能否解释一下您为解决此问题所做的工作?
    • 我不知道如何,但这个解决方案对我有用。我有配置错误说:HTTP Error 404.7 - Not Found. The request filtering module is configured to deny the file extension. 试图在新的Azure Cloud ServiceRole 中运行现有的wcf 项目。我在现有wcf 项目的web.config 中添加了这些行,它起作用了
    • @zeeshan 我不会花太多时间对 Azure 服务器配置进行故障排除......还有其他一些问题。
    猜你喜欢
    • 2014-02-10
    • 2011-12-06
    • 1970-01-01
    • 2012-12-14
    • 2019-12-06
    • 1970-01-01
    • 1970-01-01
    • 2018-11-30
    • 2023-02-01
    相关资源
    最近更新 更多