1

I got maximum request length exceeded error, trying to download a file from the site (developed in asp.net). I did tried the solution advised in the link below Maximum request length exceeded.

But i still have the same error.

the iss i am using is 8.5 [1]: https://i.stack.imgur.com/pCLEs.png i have the below tags added to the web.conf

   <security>
    <requestFiltering>
      <requestLimits maxAllowedContentLength="1073741824" />
    </requestFiltering>
      </security>

When i add the below tag it throws "500 - Internal server error."

 <httpRuntime maxRequestLength="1048576" />

but nothing seems to work.

Rinu
  • 354
  • 2
  • 6
  • 18

1 Answers1

0

The default maximum file upload size for IIS is 4MB. Uploading more than 4MB file will give an error "Maximum request length exceeded".

machine.config file is set to 4MB default limit. We can change it using the following code in the web.config.

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

For IIS 7 and later versions, we can modify the default upload limit. You will need to add the following code to the web.config.

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

maxAllowedContentLength is estimated in bytes maxRequestLength is estimated in kilobytes. default value for maxRequestLength is 4096 (4mb). max value is 2,147,483,647 default value for maxAllowedContentLength is 30,000,000 (around 30mb). max value is 4,294,967,295.

you can set value based on your file size. above maxRequestLength value is 20MB and maxAllowedContentLength 30MB. also do not forget to set the execution timeout or connectionTimeout value.

connectionTimeout specifies the time (in seconds) that IIS waits before it disconnects a connection that is considered inactive.

executionTimeout specifies the maximum number of seconds that a request is allowed to execute before being automatically shut down by ASP.NET.

Reference link:

https://learn.microsoft.com/en-us/iis/configuration/system.applicationHost/sites/siteDefaults/limits#005

https://learn.microsoft.com/en-us/previous-versions/dotnet/netframework-4.0/e1f13641(v=vs.100)?redirectedfrom=MSDN#Anchor_0

Jalpa Panchal
  • 8,251
  • 1
  • 11
  • 26