Click here to Skip to main content
14,740,854 members
Please Sign up or sign in to vote.
2.00/5 (4 votes)
I am working on the demo project for File Upload mechanism in ASP.Net c#.

I tested that demo on my local machine and it is working fine for file with 520 kb file size. But when I try to upload file with 19.20 mb file size, it gives an following error:

Server Error in '/' Application.

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.

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.

Stack Trace: 


[HttpException (0x80004005): Maximum request length exceeded.]
   System.Web.HttpRequest.GetEntireRawContent() +9784302
   System.Web.HttpRequest.GetMultipartContent() +63
   System.Web.HttpRequest.FillInFormCollection() +160
   System.Web.HttpRequest.EnsureForm() +69
   System.Web.HttpRequest.get_Form() +13
   System.Web.HttpRequest.get_HasForm() +9781235
   System.Web.UI.Page.GetCollectionBasedOnMethod(Boolean dontReturnNull) +95
   System.Web.UI.Page.DeterminePostBackMode() +69
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +220

Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.6.1038.0


What I have tried:

I tried to add some line of code in web.config as suggested in some question related to this, which is as follows:

<system.webServer>
  <security>
    <requestFiltering>
      <requestLimits maxAllowedContentLength="1073741824" />
    </requestFiltering>
  </security>
</system.webServer>
Posted
Updated 20-Oct-20 1:23am

Add following lines of code in your web.config.

<system.web>
  <httpRuntime maxRequestLength="1073741824" targetFramework="4.5" />
</system.web>


if you are running on IIS 7 or later add following lines.

<system.webServer>
  <security>
    <requestFiltering>
      <requestLimits maxAllowedContentLength="1073741824" />
    </requestFiltering>
  </security>
</system.webServer>
   
Follow instructions given here.
IIS File Upload Size Limits[^]
   
Comments
Darshan j 14-Apr-16 5:26am
   
I have not deployed the Application on IIS server.

Just running the Application using visual studio.
Member 12003400 14-Apr-16 5:37am
   
can you add
httpruntime maxrequestlength="2097151"

in your webconfig?
Darshan j 14-Apr-16 5:43am
   
I have added

requestLimits maxAllowedContentLength="1073741824"

this line in web.config.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900