ASP.NET How to Change web.config In Order To Upload Bigger Files
January 11th, 2010
No comments
When you want to upload files using FileUpload and asp.net you have a limit of 4 MB per request.
This is the default maximum file size set in machine.config. In order to change that and expand the upload limit to 10MB, you need to override it in web.config.
<system.web> <httpRuntime executionTimeout="240" maxRequestLength="10240" /> </system.web>
Most of the times you want to upload a big file in a specific folder and not your whole website, take for example the Uploads folder where you usually store images, video, audio. In order to do this you can use the location tag. An example is the following:
<location path="Uploads">
<system.web>
<httpRuntime executionTimeout="110" maxRequestLength="10240" />
</system.web>
</location>
The full list of properties is shown on the following example:
<httpRuntime executionTimeout="110" maxRequestLength="10240" requestLengthDiskThreshold="80" useFullyQualifiedRedirectUrl="false" minFreeThreads="8" minLocalRequestFreeThreads="4" appRequestQueueLimit="5000" enableKernelOutputCache="true" enableVersionHeader="true" requireRootedSaveAsPath="true" enable="true" shutdownTimeout="90" delayNotificationTimeout="5" waitChangeNotification="0" maxWaitChangeNotification="0" enableHeaderChecking="true" sendCacheControlHeader="true" apartmentThreading="false" />