File size limitations with the File Field Control in ASP.NET

By default, the maximum size of a file to be uploaded to the server using the File Field control is around 4MB. But we can make some changes in either the machine.config or web.config to increase or decrease the size limitations:

In the machine.config file, find a node called <httpRuntime> that looks like the following:

<httpRuntime
executionTimeout = “90”
maxRequestLength = “4096”
useFullyQualifiedRedirectUrl = “false”
minFreeThreads = “8”
minLocalRequestFreeThreads = “4”
appRequestQueueLimit = “1000”
/>

A lot is going on in this single node, but the setting that takes care of the size of the files to be uploaded is the maxRequestLength attribute. This is by default set to 4096KB. To increase the size of the files that you can upload to the server, simply change its value. If you want to allow 11MB files to be uploaded to the server, set the maxRequestLength value to 11000, meaning that the application allows files that are up to 11000KB to be uploaded to the server.

In web.config file, make sure that this node resides between the <system.web> nodes in the configuration file.

Another setting that is involved in the size limitation of files to be uploaded is the value that is given to the executionTimeout attribute in the <httpRuntim> node.

The value given the executionTimeout attribute is the number of seconds that the upload is allowed to occur before being shut down by ASP.NET. If you are going to allow rather large files to be uploaded to the server, you are also going to want to increase this value along with the maxRequestLength value.

Leave a Reply

avatar
  Subscribe  
Notify of