asp.net file upload control with large data file

asp.net file upload control while uploading the file with large data

By default, IIS7 limits file upload to 30MB.  Oddly, it returns a 404 error if someone uploads something larger than 30MB.



SERVER ERROR
404-FILE OR DIRECTORY NOT FOUND THE RESOURCE YOU ARE LOOKING FOR MIGHT HAVE BEEN REMOVED, HAS ITS NAME CHANGE, OR IS TEMPORARILY UNAVAILABLE.
you can override machine.config file size and time out by doing this entry in your app web.config file
<system.web>
    <httpRuntime
 executionTimeout="3600"
 maxRequestLength="1024000"
 requestLengthDiskThreshold="80"
 useFullyQualifiedRedirectUrl="false"
 minFreeThreads="8"
 minLocalRequestFreeThreads="4"
 appRequestQueueLimit="5000"
 enableKernelOutputCache="true"
 enableVersionHeader="true"
 requireRootedSaveAsPath="true"
 enable="true"
 shutdownTimeout="3600"
 delayNotificationTimeout="3600"
 waitChangeNotification="0"
 maxWaitChangeNotification="0"
 enableHeaderChecking="true"
 sendCacheControlHeader="true"
 apartmentThreading="false" />
    
</system.web>

Here 
maxRequestLength 
is in KB
there is an alternate solution that can be enabled at the site level rather than server-wide.
              <system.webServer>
        <security>
            <requestFiltering>
                <requestLimits maxAllowedContentLength="1024000000"/>
            </requestFiltering>
        </security>
</system.webServer>

If you add the above code to the web.config file for your site, you can control the maximum upload size for your site.  In many cases, the system.webServer node will already be in the file, so just add the security node within that.
Note that the maxAllowedContentLength is in BYTES not kilobytes.
You may also need to restart your Web site (not the whole server) to enable the setting.
It allow upload upto 1 GB now ...

Comments

Syam Sukumar said…
Thanks Vinod, Its a nice posting, I did the changes as you suggested and my application working fine..

-syam