Total Pageviews

Friday, April 27, 2012

Uploading Large files in asp.net and IIS 7.0 and higher

Hi,

I'm hoping this would be helping out many of alike programmers facing file upload issue with asp.net, as it took me few different troubleshooting paths to eventually get large files uploading functional for the applications that were working perfectly fine UNTIL I moved these application to IIS 7.0 from IIS 6.0.

Recently I migrated our hosting servers from IIS 6.0 to IIS 7.5 including all the source code and mark-up files(in c#.net). Since that day applications with "FileUpload" functionality started displaying "Page cannot be displayed" message when ever large files were uploaded.

I tried increasing executionTimeOut and maxRequestLength (which would be the first thought in every developer's mind) but it didn't worked. Finally the solution to this issue (asp.net file upload on IIS 7.0 or higher) turned out to be the changed web.config element to cater larger files!!

In <system.webServer> you need add the following line of code and it would definitely work for large uploads:
       <security>
            <requestFiltering>
                <requestLimits maxAllowedContentLength="2294967296" />
            </requestFiltering>
        </security>

Make sure your session timeout value is high enough to keep the upload happening else your page would expire regardless.

Thank you,

No comments:

Post a Comment