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 a size larger than 4 MB, you will start seeing this error.
Server Error in '/' Application.
------------------------------
Maximum request length exceeded.
Solution :
< httpRuntime executionTimeout="240" maxRequestLength="20480" / >
< /system.web >
For IIS 7 and later versions, we can modify the default upload limit to 30 MB. 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.