ASP.Net Error : Maximum request length exceeded.

In ASP.Net, while uploading large files using FileUpload control, you may have experienced an error saying that "Maximum request length exceeded". The default value of Maximum upload file size is set to 4 MB. In most cases, this limit is set to avoid DDoS attacks, large file uploads and few other reasons. So, when you try to upload a file with the size larger than 4 MB, you will start seeing this error.


Server Error in '/' Application.
------------------------------
Maximum request length exceeded.

Solution :


The default maximum file upload size for IIS is 4MB. Uploading more than 4MB file will give an error "Maximum request length exceeded"

machine.config file is set to 4MB default limit. We can change it to 20MB using the following code in the web.config.

< system.web >
< httpRuntime executionTimeout="240" maxRequestLength="20480" / >
< /system.web >

For IIS 7 and later versions, we can modify the default upload limit to 30MB. You will need to add the following code to the web.config.

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

Note:

maxAllowedContentLength is estimated in bytes
maxRequestLength is estimated in kilobytes.
  • 0 Users Found This Useful

Was this answer helpful?