Blog: IIS7

In IIS6 you allowed large file uploads to an ASP.NET website by adding the following key to the web.config:

<httpRuntime maxRequestLength="102400"
     useFullyQualifiedRedirectUrl="true"
     executionTimeout="900" />

You would just set the maxRequestLength to a number of kilobytes that is greater than the size of the largest file you plan to upload.  We recently moved a site from a server running IIS6 to IIS7.  After the move, when our website users were having problems uploading large files.  They would submit a form, the progress bar would move for a while, then they would get a 404 page not found error.  The form was posting back to itself, so the page did exists.  Turns out we needed to add an additional web.config setting that’s new to IIS7. [more]

    <system.webServer>
        <security>
            <requestFiltering>
                <requestLimits maxAllowedContentLength=" 104857600"/>
            </requestFiltering>
        </security>
    </system.webServer>

The maxAllowedContentLength in this settings is specified in bytes.

Note: These settings exist to help revent denial of service attacks, so keep that in mind when you pick your limits.


 

For a little added security you can move your inetpub directory to a seperate partition from your operating system files.  By default the IIS7 Inetpub directory is created on the same partition as the Window Server 2008 install.  There is no way to specify a different location during the setup process.  You can create a new inetpub directory on a different partition, set the correct permissions, and change all the IIS settings to point to the new directory.  However, a program manager on the IIS team wrote a great script that will do all that for you.  Here are the steps to move inetpub using his batch file: [more]

  • First download the batch file from his blog post.
  • Unzip the batch file
  • Open a command prompt
  • Browse to the directory where you unzipped the batch file
  • Type "moveiis7root.bat" <the drive letter of the partition you would like to move it to> and press enter

Example: "moveiisroot.bat w"

If the batch file runs successfully you'll have a new inetpub directory on the partition you specified with the correct access permissions set and IIS will be configured to use the new folder.  You can then delete the old c:\inetpub directory.