File Upload Limits in ASP.net

I worked on a project recently that required me to allow users to upload files to a server. Easy enough, i added a file upload control on a page and things seemed to be working fine.

Today i got a bug that large files could not be uploaded. I did some digging and found out that the default size allowed by ASP.net is 4 MB. But this can changed. All you need to do is add the following httpRuntime tag in your web.config file under the <system.web> tag. The max size you want to allow to be uploaded goes into maxRequestLength=”4096″ I set it to maxRequestLength=”102400″ which is 100 MB.

<httpRuntime
 executionTimeout="110"
 maxRequestLength="4096"
 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" />

I found this at http://www.codedigest.com/FAQ/18-How-to-increase-default-File-Upload-size-in-ASP-Net–.aspx

Advertisements