a blog for those who code

Monday 23 June 2014

Error : Maximum request length exceeded

You got this error because you are trying to sent data more than the default size it can handle. If you are hosting your application over IIS, then the default data size is 4MB. So if you are trying to send data more than 4MB you will get "Maximum request length exceeded" error.

If you want to increase the default size, you have to assign maxRequestLength in web.config file.

<configuration>
    <system.web>
        <httpRuntime maxRequestLength="" executionTimeout="360"/>
    </system.web>
</configuration>

When you are sending a large data you should also specify the execution timeout as mentioned above. The above case is only valid if you have IIS 6 or lower, if you have IIS 7 or higher in addition to this code you also need to add below code in your web.config file...

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

One thing to remember that your maxAllowedContentLength should be 1024 times your maxRequestLength. For example if you are using 1024 as maxRequestLength then you should use 1048576.

Please Like and Share the Blog, if you find it interesting and helpful.

No comments:

Post a Comment