Maximum request length exceeded.

2018-12-31 02:08发布

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?

14条回答
美炸的是我
2楼-- · 2018-12-31 02:20

I was tripped up by the fact that our web.config file has multiple system.web sections: it worked when I added < httpRuntime maxRequestLength="1048576" /> to the system.web section that at the configuration level.

查看更多
梦寄多情
3楼-- · 2018-12-31 02:24

It bothered me for days too. I modified the Web.config file but it didn't work. It turned out that there are two Web.config file in my project, and I should modified the one in the ROOT directory, not the others. Hope this would be helpful.

查看更多
零度萤火
4楼-- · 2018-12-31 02:29

It may be worth noting that you may want to limit this change to the URL you expect to be used for the upload rather then your entire site.

<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>
查看更多
倾城一夜雪
5楼-- · 2018-12-31 02:30

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)

查看更多
余生无你
6楼-- · 2018-12-31 02:32

maxRequestLength (length in KB) Here as ex. I took 1024 (1MB) maxAllowedContentLength (length in Bytes) should be same as your maxRequestLength (1048576 bytes = 1MB).

<system.web>
   <httpRuntime maxRequestLength="1024" executionTimeout="3600" />
</system.web>

<system.webServer>
   <security>
      <requestFiltering>
          <requestLimits maxAllowedContentLength="1048576"/>
      </requestFiltering>
   </security>
</system.webServer>
查看更多
零度萤火
7楼-- · 2018-12-31 02:35

If you have a request going to an application in the site, make sure you set maxRequestLength in the root web.config. The maxRequestLength in the applications's web.config appears to be ignored.

查看更多
登录 后发表回答