The maxRequestLength indicates the maximum file upload size supported by ASP.NET, the maxAllowedContentLength specifies the maximum length of content in a request supported by IIS. Hence, we need to set both maxRequestLength and maxAllowedContentLength values to upload large files.
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).
According to MSDN maxAllowedContentLength has type uint , its maximum value is 4,294,967,295 bytes = 3,99 gb. So it should work fine.
The MaxRequestLength property specifies the limit for the buffering threshold of the input stream. For example, this limit can be used to prevent denial of service attacks that are caused by users who post large files to the server.
maxRequestLength indicates the maximum request size supported by ASP.NET, whereas maxAllowedContentLength specifies the maximum length of content in a request supported by IIS. So you need to set both in order to upload large files: the smaller one "takes priority".
(I picked this up from http://forums.iis.net/t/1169846.aspx -- credit where it's due.)
You can set both to be local to a specific site or even a folder within a site by editing the appropriate web.config file. If the file (well, request) length is less than maxAllowedContentLength but more than maxRequestLength, the user will get your standard (ASPX) error page, if you have one. If it's the other way around, he'll get an IIS error page instead. For that reason, you might want to have maxAllowedContentLength to a very large value (just for this website/folder) and then have the limiting value be maxRequestLength.
Finally, remember that maxRequestLength is in KB whereas maxAllowedContentLength is in BYTES!
The short and sweet answer is that the smaller of the two will take precedence. A word of advice though- in my opinion it is advisable to set maxRequestLength to be the smaller of the two as you can catch an exception in the Application_Error event of your Global.asax should it be exceeded. If you exceed maxAllowedContentLength first IIS will deal with it instead of ASP.NET, making it trickier to deal with in code.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With