Tuesday, March 4, 2008

ASP .NET File Upload Problem

When I upload a large file (> 4MB), I started getting error - "The page cannot be displayed". It took me 15 minutes before I realized that maxRequestLength is causing this problem.

By default, the maxRequestLength will be 4MB. If you are uploading a file which is larger than 4MB, please be sure to edit your web.config file by using httpRuntime attribute.

httpRuntime attribute has several properties, but the attributes that you need to take note are executionTimeout and maxRequestLength. The executionTimeout is the maximum time in seconds a request is allowed to execute before being shut down by ASP .NET automatically, default is 110s. While maxRequestLength is maximum file length that will be uploaded, in kilobytes, default is 4MB.

To set this in your web.config, it should look like as below:

<httpRuntime executionTimeout="600" maxRequestLength="1024000000" />

Hope this can help someone. Cheers!

0 comments:

 

Get paid for your opinions! Click on the banner above to join Planet Pulse. Its totally free to sign up, and you can earn UNLIMITED. Find out more by visiting PLANET PULSE.
July Code Blog Copyright © 2010 Blogger Template Designed by Bie Blogger Template