IIS7 - 请求筛选模块配置为拒绝超过请求内容长度的请求

skm*_*asq 59 asp.net iis iis-7 asp.net-mvc-3

我想上传图片,它在我的机器上工作正常,但当我把我的网站放在IIS7服务器上公开时,我无法上传任何内容.

错误

请求过滤模块被配置为拒绝超过请求内容长度的请求.

最可能的原因

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

你可以尝试的事情

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

Web.config中的system.webServer

  <system.webServer>
    <validation validateIntegratedModeConfiguration="false" />
    <modules runAllManagedModulesForAllRequests="true" />
    <security>
      <requestFiltering>
         <requestLimits maxAllowedContentLength="1048576" />
      </requestFiltering>
   </security>
  </system.webServer>
Run Code Online (Sandbox Code Playgroud)

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

Sta*_*tan 39

<configuration>
    <system.web>
        <httpRuntime maxRequestLength="1048576" />
    </system.web>
</configuration>
Run Code Online (Sandbox Code Playgroud)

这里开始.

  • 你错过了一半的故事......你还需要配置**MaxAllowedContentLength** (21认同)
  • @LaPuyaLoca是正确的,这是一半的答案,我认为[此处]提供了完整的答案(http://stackoverflow.com/a/40085473/2912011)。 (2认同)