System.Web.HttpException Maximum request length exceeded edit button Edit

Murugan Andezuthu Dharmaratnam | calendar 10 February 2021 | 2679

I was getting this error while I was trying to upload an image to an asp .net mvc application.

Exception Details

500 Internal Server Error.

Maximum request length exceeded.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Web.HttpException: Maximum request length exceeded.


The solution is to modify the web.config file and add the following.

  <httpRuntime maxRequestLength="20480" />

The maximum request size in kilobytes. The default size is 4096 KB (4 MB). This limit can be used to prevent denial of service attacks that are caused by some users who might post large files to the server. If this does not help & if you are using IIS7 and above, you try add the lines below:
         <requestLimits maxAllowedContentLength="1073741824" />