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

ASP.NET 网站上传文件超过4M时会出现Web 服务器上的请求筛选被配置为拒绝该请求,因为内容长度超过配置的值 的错误
解决方案:

修改web.config中 system.web/ httpRuntime.maxRequestLength
修改web.config中 system.webServer/ security/ requestLimits.maxAllowedContentLength

<system.web>
     <httpRuntime maxRequestLength="4096" />
</system.web>
 
<system.webServer>
    <security>
       <requestFiltering>
        <requestLimits maxAllowedContentLength="30000000" />
      </requestFiltering>
    </security>
 </system.webServer>

参考配置:

 <system.web>
    <compilation debug="true" targetFramework="4.6.2" />
    <httpRuntime maxRequestLength="1048576000" executionTimeout="3600" targetFramework="4.5" />
 </system.web>

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

原文地址:https://www.cnblogs.com/ShaYeBlog/p/11166873.html