Condividi tramite


error Element for httpErrors [IIS Settings Schema]

Note

For more information about the error element, see the following topic on the Microsoft IIS.net Web site: Adding HTTP Errors <error>.

Adds an HTTP error to the collection of HTTP errors.

Syntax

Attributes and Elements

The following sections describe attributes, child elements, and parent elements for this section.

Attributes

Attribute

Description

path

Required string attribute.

Specifies the file path or URL that is served in response to the HTTP error specified by the statusCode and subStatusCode attributes. If you choose the File response mode, you specify the path of the custom error page. If you choose the ExecuteURL response mode, the path has to be a server relative URL (for example, /404.htm). If you choose the Redirect response mode, you have to enter an absolute URL (for example, www.contoso.com/404.htm).

prefixLanguageFilePath

Optional string attribute.

Specifies the initial path segment when generating the path for a custom error. This segment appears before the language-specific portion of the custom error path. For example, in the path c:\inetpub\custerr\en-us\404.htm, "c:\inetpub\custerr" is the prefixLanguageFilePath.

responseMode

Optional enum attribute.

Specifies how custom error content is returned.

The responseMode attribute can be one of the following possible values. The default is File.

ValueDescription
FileServes static content, for example, a .html file for the custom error. If responseMode is set to File, the path attribute value has to be a file path. The numeric value is 0.
ExecuteURLServes dynamic content (for example, an .asp file) specified in the path attribute for the custom error. If responseMode is set to ExecuteURL, the path value has to be a server relative URL. The numeric value is 1.
RedirectRedirects client browsers to a the URL specified in the path attribute that contains the custom error file. If responseMode is set to Redirect, the path value has to be an absolute URL. The numeric value is 2.

statusCode

Required integer attribute.

Specifies the number of the HTTP status code for which you want to create a custom error message. Acceptable values are from 400 through 999.

subStatusCode

Optional integer attribute.

Specifies the number of the HTTP substatus code for which you want to create a custom error message. Acceptable values are from -1 through 999.

Child Elements

None.

Parent Elements

Element

Description

configuration

Specifies the root element in every configuration file that is used by IIS 7.

system.webServer

Specifies the top-level section group (in ApplicationHost.config) in which this element is defined.

httpErrors

Configures HTTP error messages for a Web server.

Remarks

For more information about the error element, see the following topic on the Microsoft IIS.net Web site: Adding HTTP Errors <error>.

Element Information

Configuration locations

Machine.config

ApplicationHost.config

Root application Web.config

Application Web.config

Directory Web.config

Requirements

Microsoft Internet Information Services (IIS) version 7.0

See Also

Reference

remove Element for httpErrors [IIS Settings Schema]

clear Element for httpErrors [IIS Settings Schema]