This post has 2 Replies | 2 Followers

Top 10 Contributor
Male
Posts 33
Md. Elias Hossain Posted: 04-30-2009 6:28 PM

Normal 0 false false false EN-US X-NONE X-NONE MicrosoftInternetExplorer4

Limiting the 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.

To change this size limit, you have to make some changes in the application's web.config:

<system.web>
  <httpRuntime  maxRequestLength="102400" executionTimeout="360"/>
</system.web>

maxRequestLength (in KB) - Attribute limits the file upload size for ASP.NET application. This limit can be used to prevent denial of service attacks (DOS) caused by users posting large files to the server. The size specified is in kilobytes. As mentioned earlier, 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 ( in seconds) - Attribute indicates the maximum number of seconds that a request is allowed to execute before being automatically shut down by the application. The executionTimeout value should always be longer than the amount of time that the upload process can take.

Md. Elias Hossain
MCP, MCTS(WEB)
Software Engineer

Top 25 Contributor
Male
Posts 21

Thanks for your useful post. I used that techniq back in 2008 to develop an Internal Version Control web site.I used to make release of the working software and someTimes the release folder got more than 40MB big in size, and I had to Upload that to my Server as a Zip file,  Didn't know about the Maximum value, but I guess my software release won't get bigger than 2 GB. Thanks.

Ashfaq

ECDS

Top 10 Contributor
Male
Posts 33

Hi,
   Use maxRequestLength to limit maximum and executionTimeout for execution time, your application will support according to these properties.

Thanks

Md. Elias Hossain
MCP, MCTS(WEB)
Software Engineer

Page 1 of 1 (3 items) | RSS