s

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

author
Murugan Andezuthu Dharmaratnam | calendar 10 February 2021 | 2603

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.

Solution

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

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


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:
<system.webServer>
   <security>
      <requestFiltering>
         <requestLimits maxAllowedContentLength="1073741824" />
      </requestFiltering>
   </security>
 </system.webServer>