1. Background:

Generally, an ASP.NET web site may only accept a request with less than 4 Mb size. If you want your site can accept large file uploading, you must modify the default settings in IIS, as well as the web.config file in your web application.

2. Steps:

  1. Increase the upload size limit under Request Filter Setting in IIS (Below steps applies for IIS 7, 7.5).

    1. Open IIS Console using INETMGR command (or IIS command) in Run window.
      • image
    2. In the Connections pane, select your web site under Sites node.
    3. In the Feature View of IIS pane, double-click Request Filtering.
      • image
    4. Click Edit Feature Settings… in the Actions pane.
    5. Under Request Limits set Maximum allowed content length (Bytes): to the value you want, and then click OK.
      • image
  2. Add following code snippet in the web.config file.

    1. Define maxAllowedContentLength under <system.webServer>node.
      • <security>
                    <requestFiltering>
                        <!-- Setting maximum request size to 6MB -->
                        <!-- NOTE: See 'httpRuntime' element above.-->
                        <requestLimits maxAllowedContentLength="6291456"/>
                    </requestFiltering>
               </security>
    2. Modify the maxRequestLength value under <httpRuntime> node. (Warning: size is mentioned in KB, not bytes)
      • <httpRuntime requestValidationMode="2.0"
                            maxRequestLength="6144" 
                            requestLengthDiskThreshold="6144" />