Default Document <defaultDocument>

Overview

The <defaultDocument> element allows you to enable or disable default document behavior for your Web site or application. This element contains a <files> child element, which contains a collection of <add> elements. Each <add> element defines the default documents that the site or application will return to a client browser when the site receives a request to the root directory.

The <defaultDocument> element can also contain one or more <remove> elements. Each <remove> element removes a specific default document file inherited from a higher-level configuration file on the Internet Information Services (IIS) 7 server. You can also use the <clear> element to remove all default document settings defined higher in the configuration hierarchy.

Default documents are enabled by default, and IIS 7 defines the following default document files in the ApplicationHost.config file as server-wide defaults:

Default.htm

Default.asp

Index.htm

Index.html

Iisstart.htm

(If you install ASP.NET on your Web server, the installation process will add the Default.aspx file to this list.)

By default, when a request arrives for your site's or application's root directory, IIS 7 sends a response to the browser based on the file names you defined in the <defaultDocument> element. IIS attempts to return the correct files in the order that they appear in the <defaultDocument> element. If the Default.htm file exists, IIS sends it to the client browser. If the Default.htm file does not exist, IIS attempts to send the Default.asp file to the browser, and if the Default.asp file does not exist, IIS attempts to send the Index.htm file to the browser. IIS continues in this manner until it attempts to send each default document file to the client browser.

Note: If you order this list of default documents correctly, you can improve the performance of IIS. For example, if you intended to use Index.php for the home page in all the folders of your Web site and you add Index.php to the bottom of the list of default documents, IIS will have to check for each of the default documents in the list before attempting to return Index.php to the client browser. Depending on the number of folders in your Web site and the number of client browser requests, this may impact your performance.

If you disable default documents but have enabled directory browsing, IIS returns a directory listing when a request for the root directory arrives from a browser. If you disable both default documents and directory browsing, IIS sends an "HTTP 404 File Does Not Exist" error to the browser.

Compatibility

Version

Notes

IIS 8.5

The <defaultDocument> element was not modified in IIS 8.5.

IIS 8.0

The <defaultDocument> element was not modified in IIS 8.0.

IIS 7.5

The <defaultDocument> element was not modified in IIS 7.5.

IIS 7.0

The <defaultDocument> element was introduced in IIS 7.0.

IIS 6.0

The <defaultDocument> element replaces the IIS 6.0 DefaultDoc property and the EnableDefaultDoc value of the DirBrowseFlags property on the IIsWebService metabase object.

Setup

The <defaultDocument> element is included in the default installation of IIS 7.

Attributes

Child Elements

Specifies a list of file names that can be returned as default documents.

Configuration Sample

The following configuration example, when included in a Web.config file for a site or application, enables default documents for the site or application. It then adds the file name "Home.html" to the list of the site's or application's default documents.