Sunday, July 21, 2013

Server Error in '/' Application, Maximum request length exceeded

Below is one of the common error developers get when they try to upload huge files using ASP.NET application.

Error description:

Server Error in '/' Application.
--------------------------------------------------------------------------------

Maximum request length exceeded.
Description: An unhanded 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.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Reason:

users are trying to upload huge files which is more than the default size allowed by .NET Framework.

Solution:

Change below settings in web.config depends on the IIS version you are using.

For IIS6

<configuration>
    <system.web>
        <httpRuntime maxRequestLength="1048576" />
    </system.web>
</configuration>

For IIS7

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

You may change the values depends on the file size you want to allow the users to upload.

Try to run your application and upload some files!!!

No comments: