Tuesday, 4 September 2012

How to increase default File Upload size in ASP.Net ?

By default, the maximum size of a file to be uploaded to a server using the ASP.NET FileUpload control is 4MB. You cannot upload anything that is larger than this limit.

This value can be increased by modifying the maxRequestLength attribute in the web application's configuration file (web.config)

To change this size limit, you have to make some changes in the application's web.config:
    <httpRuntime maxRequestLength="1048576" executionTimeout="3600" />

maxRequestLength - This attribute is used to limit the size of uploads by rejecting any which exceed a certain limit. The limit refers to the total size of the HTTP upload in KB (approximately equal to the sum of all the files being upload). You should set a sensible limit here to stop malicious visitors using up your bandwidth by uploading excessively large files.

If the size of an upload is too great the server will refuse to accept it. Because the server is refusing the request the uploading browser will report that the submission page is not available. This is a client side error message rather than a server side error message and it means that you cannot normally provide a sensible error message to users if they submit files which are too large.

The default is "4096" (4 MB).

Max value is "1048576" (1 GB) for .NET Framework 1.0/1.1 and "2097151" (2 GB) for .NET Framework 2.0.

ExecutionTimeout -  The execution time-out refers to the number of seconds an ASP.NET page is given before the operation is assumed to have failed and the page terminated. If you are uploading a large file the code that is receiving the transfer may time out before the file has been completely uploaded.

No comments:

Post a Comment