Aug 29 2012

Fixing File Upload Size Limit in IIS 7

I am product manager for a .NET application that contains functionality to upload and download files. Just when I thought everything was running smoothly, we ran into a file size upload limit which I thought we had already adjusted using the maxRequestLength attribute of the element.

After spending an hour on my own trying to figure out why the heck my .NET application was failing with all sorts of timeout errors when trying to upload a large file around 40 MB. I decided to do some further research into the configuration parameters in IIS 7 and the application’s web.config.

Turns out that Windows 2008 Server and IIS 7 have different behavior and configuration settings than IIS 6 and IIS 5. In the older IIS versions, the following code within the element in the web.config file in the web application’s folder controlled the maximum file upload size:

This allows a file upload of 2,000,000 KB (2 GB) and it will time out after 3,600 seconds (1 hour).

Adjusting File Size Limit in IIS 7

The problem is that in IIS 7 on Windows 2008 Server, the default maximum file size is 30 MB. Even with the maxRequestLength attribute set higher, the web application will reject any file that is larger than 30 MB. In order to upload files larger than 30 MB, the following code must be added to the element in the web.config file:


With the above maxAllowedContentLength, users can upload files that are 2,000,000,000 bytes (2GB) in size.

Maximum File Upload Size in IIS 7

Since the maxAllowedContentLength is an int (Int32) data type, then the maximum value is 2,147,483,647.

Permanent link to this article:

Leave a Reply