Auto Ad Code

Friday, July 2, 2010

Large File Upload

Days back I was trying to upload a larger file to my website (which was recently shifted to IIS7 from IIS6) when I start getting weird error and most common was
"404 not found
The requested document was not found on this server."


with almost a blank white page. I checked my web.config for maxRequestLength attribute and which was properly set that is maxRequestLength = 10240 i.e. I was allowing 10 MB file to be uploaded whereas the file I was trying to upload was just 3 MB, and it was known that files under 10 MB were successfully uploaded in past.

I started googling for the error but unfortunately there wasn't much about this error over the internet.
Started thinking that what special was done with the website recently. There wasn't anything special but the shift from IIS6 to IIS7.

Now when I searched for setting file size in IIS7 I came to know that maxRequestLength is no more functional in IIS7. We have to set maxAllowedContentLength under . Made the required change and whoaaa it start working again.
A thing to remember is that maxAllowedContentLength takes value in Bytes whereas maxRequestLength accepts value in Kilo Bytes.
So to set maxAllowedContentLength for 10MB you have to set maxAllowedContentLength = 10485760.
Following is the web.config code which should be set for IIS7 to allow 10MB(say) files.

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


No comments:

Post a Comment