Maximum request length exceeded.

I am getting the error Maximum request length exceeded when I am trying to upload a video in my site.

How do I fix this?


If you are using IIS for hosting your application, then the default upload file size if 4MB. To increase it, please use this below section in your web.config -

<configuration>
    <system.web>
        <httpRuntime maxRequestLength="1048576" />
    </system.web>
</configuration>

For IIS7 and above, you also need to add the lines below:

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

Note :

  • maxRequestLength is measured in kilobytes
  • maxAllowedContentLength is measured in bytes
  • which is why the values differ in this config example. (Both are equivalent to 1 GB)


    I don't think it's been mentioned here, but to get this working, I had to supply both of these values in the web.config:

    In system.web

    <httpRuntime maxRequestLength="1048576" executionTimeout="3600" />
    

    And in system.webServer

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

    IMPORTANT : Both of these values must match. In this case, my max upload is 1024 megabytes.

    maxRequestLength has 1048576 KILOBYTES, and maxAllowedContentLength has 1073741824 BYTES.

    I know it's obvious, but it's easy to overlook.


    值得注意的是,您可能希望将此更改限制为您希望用于上传的网址,而不是整个网站。

    <location path="Documents/Upload">
      <system.web>
        <!-- 50MB in kilobytes, default is 4096 or 4MB-->
        <httpRuntime maxRequestLength="51200" />
      </system.web>
      <system.webServer>
        <security>
          <requestFiltering>
            <!-- 50MB in bytes, default is 30000000 or approx. 28.6102 Mb-->
            <requestLimits maxAllowedContentLength="52428800" /> 
          </requestFiltering>
        </security>
      </system.webServer>
    </location>
    
    链接地址: http://www.djcxy.com/p/42062.html

    上一篇: 配置错误:此配置节不能用于此路径

    下一篇: 超过最大请求长度。