Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set the maxAllowedContentLength to 500MB while running on IIS7?

I changed the maxAllowedContentLength to

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

In my web.config, but when running on IIS7 I get this error:

The 'maxAllowedContentLength' attribute is invalid. Not a valid unsigned integer

http://i.stack.imgur.com/u1ZFe.jpg

but when I run in the VS server it run normally without any errors.

How to config my website to allow upload files with 500MB size, without this problem on IIS7?

like image 542
Amr Elgarhy Avatar asked Oct 26 '10 09:10

Amr Elgarhy


People also ask

How do I change maxAllowedContentLength?

Type inetmgr in windows Run (WinKey + r) click your server name on left panel and in right panel in IIS section double click Request Filtering. on the rightest panel click Edit Feature Settings... . In Request Limits section you can change the maxAllowedContentLength.

What is the max maxAllowedContentLength?

According to MSDN maxAllowedContentLength has type uint , its maximum value is 4,294,967,295 bytes = 3,99 gb. So it should work fine.

What is maximum value for maxRequestLength?

HttpRuntime maxRequestLength Use the maxRequestLength of the httpRuntime element. The default size is 4096 kilobytes (4 MB). Max value 2,147,483,647 kilobytes (~82 Terabyte).


2 Answers

According to MSDN maxAllowedContentLength has type uint, its maximum value is 4,294,967,295 bytes = 3,99 gb

So it should work fine.

See also Request Limits article. Does IIS return one of these errors when the appropriate section is not configured at all?

See also: Maximum request length exceeded

like image 38
abatishchev Avatar answered Oct 13 '22 06:10

abatishchev


The limit of requests in .Net can be configured from two properties together:

First

  • Web.Config/system.web/httpRuntime/maxRequestLength
  • Unit of measurement: kilobytes
  • Default value 4096 KB (4 MB)
  • Max. value 2147483647 KB (2 TB)

Second

  • Web.Config/system.webServer/security/requestFiltering/requestLimits/maxAllowedContentLength (in bytes)
  • Unit of measurement: bytes
  • Default value 30000000 bytes (28.6 MB)
  • Max. value 4294967295 bytes (4 GB)

References:

  • http://www.whatsabyte.com/P1/byteconverter.htm
  • https://www.iis.net/configreference/system.webserver/security/requestfiltering/requestlimits

Example:

<location path="upl">    <system.web>      <!--The default size is 4096 kilobytes (4 MB). MaxValue is 2147483647 KB (2 TB)-->      <!-- 100 MB in kilobytes -->      <httpRuntime maxRequestLength="102400" />    </system.web>    <system.webServer>      <security>        <requestFiltering>                    <!--The default size is 30000000 bytes (28.6 MB). MaxValue is 4294967295 bytes (4 GB)-->          <!-- 100 MB in bytes -->          <requestLimits maxAllowedContentLength="104857600" />        </requestFiltering>      </security>    </system.webServer>  </location> 
like image 95
Anderson Rissardi Avatar answered Oct 13 '22 06:10

Anderson Rissardi