Uploading big file to website is always been troublesome for me. You have to modified httpRuntime Tag's maximumRequestLength and executionTimeout properties in web.config. You have to set proper size and timeout to upload big file.
Today, I faced another problem in IIS 7 regarding to big file size upload. Even though I put proper httpRuntime tag, I am not able to upload the big file. I keep getting 404 page not found error for my file upload ashx handler. When I upload small file, it's successfully uploaded.
<httpruntime maxrequestlength="40960" executiontimeout="3600"/>
Note: This is to allow 400MB (1024 *400) file and time out set to 1hour ( 60 * 60).
This is because of the IIS 7 new security feature requestFiltering. This limit can be used to prevent denial of service attacks that are caused. For example, users posting large files to the server.
The default maxRequestLength attribute specifies for requestFiltering is set to 30000000 (appx 30MB). So, if you want to upload bigger than 30 MB, you need to add in the system.webServer session, something like this:
<security>
<requestFiltering>
<requestLimits maxAllowedContentLength="419430400"/>
</requestFiltering>
</security>
<requestFiltering>
<requestLimits maxAllowedContentLength="419430400"/>
</requestFiltering>
</security>
Note: This is to allow 400MB (1024 * 1024 *400) file upload.
According to MSDN maxAllowedContentLength has type uint, its maximum value is 4,294,967,295 bytes = ~3,99 GB. You can read more details information in MSDN.
If you are uploading custom file extension for your website, don't forget to add HTTP Header for this extension. This will help you avoid showing 404 error for downloading your file.
No comments:
Post a Comment