【问题标题】:Maximum Request Length Exceeded Errors超出最大请求长度错误
【发布时间】:2017-11-22 14:17:35
【问题描述】:

我阅读了 ASP.NET MVS with Entity Framework and CSS 一书。而且我无法解决处理最大请求长度超出错误的问题。我编辑 system.web 部分并添加 maxRequestLength:

<httpRuntime targetFramework="4.6.1" maxRequestLength="20480"/>

当文件超过 20 Mb 时,我收到错误“超出最大请求长度”。 然后我更新system.webServer:

<security>
  <requestFiltering>
    <requestLimits maxAllowedContentLength="20971520"/>
  </requestFiltering>
</security>

此时,当文件超过限制时,我没有任何错误。浏览器只是等待很长时间,没有任何反应。我想为最大请求长度添加自定义错误页面。

<httpErrors errorMode="Custom">
<remove statusCode="404" subStatusCode="13"/>
<error statusCode="404" subStatusCode="13" responseMode="Redirect" path="/Error/FileUploadLimitExceeded"/>
</httpErrors>

但它也不起作用。我认为是因为 requestFiltering。有人可以帮我吗?

【问题讨论】:

    标签: asp.net iis


    【解决方案1】:

    您需要同时设置 httpRuntime.maxRequestLength 和 requestFiltering.maxAllowedContentLength`。

    类似的东西

    <configuration>
        <system.web>
            <httpRuntime
                maxRequestLength="512000"
                executionTimeout="3600"
            />
        </system.web>
    
        <system.webServer>
            <security>
                <requestFiltering>
                    <requestLimits maxAllowedContentLength="500000000" />
                </requestFiltering>
            </security>
        </system.webServer>
    </configuration>
    

    来源:https://forums.iis.net/t/1169846.aspx

    【讨论】:

    • 是的。我把所有三个:maxRequestLength、maxAllowedContentLength 和 httpErrors。最后,当发生 404.13 错误时,我应该重定向到我的自定义错误页面。但什么也没有发生。我认为iis有问题。但我找不到答案。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-04-20
    • 1970-01-01
    • 2017-03-04
    相关资源
    最近更新 更多