HttpErrorElement Class

Configures the response to a specific HTTP error.

Syntax

class HttpErrorElement : CollectionElement  

Methods

This class contains no methods.

Properties

The following table lists the properties exposed by the HttpErrorElement class.

Name Description
Path A required read/write string value that contains the file name or URL that is served in response to the HTTP error specified by the StatusCode and SubStatusCode properties.
PrefixLanguageFilePath An optional read/write string value that specifies the physical path of a custom error page directory. The custom error page directory contains one or more language-specific subdirectories with custom error pages for the error specified in the StatusCode property.

The file path is constructed as follows: PrefixLanguageFilePath\ClientLanguageID\CustomErrorPageFile. For example, PrefixLanguageFilePath might be "%SystemDrive%\inetpub\custerr", ClientLanguageID might be "en-us" and CustomErrorPageFile (specified by the Path property) might be "401.htm". Note: Custom errors are language-specific and typically return the custom error in the system language of the client. For an error page to be returned in a language different from the system language of the client, the language pack for that language must be installed on the client. For example, if PrefixLanguageFilePath is "d:\inetpub\custerr" and the client has the en-US language pack installed, the resulting path for error code 404 is d:\inetpub\custerr\en-us\404.htm when the client browser sends "en-us" in the Accept-Language header. However, if ja-JP is the system language, and the en-US language pack is not installed, the resulting path is d:\inetpub\custerr\ja-jp\404.htm.
ResponseMode A required read/write sint32 value that specifies the response to the HTTP error specified by StatusCode and SubStatusCode. The possible values are listed later in the Remarks section.
StatusCode A required unique read/write uint32 value that contains a status code from 400 through 999. A key property.
SubStatusCode A required unique read/write sint32 value that contains a substatus code from –1 through 999. The default is –1. A key property.

Subclasses

This class contains no subclasses.

Remarks

Instances of this class are contained in the HttpErrors array property of the HttpErrorsSection class.

This class represents an <error> element in the <httpErrors> section of the ApplicationHost.config file.

The following table contains the possible values and keywords for the ResponseMode property. The default is 0 (File).

Value Keyword Description
0 File The Web server returns the Web page specified in the Path property.
1 ExecuteURL The Web server returns the ASP page specified in Path.
2 Redirect The Web server redirects the request to the URL specified in Path.

Inheritance Hierarchy

CollectionElement

HttpErrorElement

Requirements

Type Description
Client - IIS 7.0 on Windows Vista
- IIS 7.5 on Windows 7
- IIS 8.0 on Windows 8
- IIS 10.0 on Windows 10
Server - IIS 7.0 on Windows Server 2008
- IIS 7.5 on Windows Server 2008 R2
- IIS 8.0 on Windows Server 2012
- IIS 8.5 on Windows Server 2012 R2
- IIS 10.0 on Windows Server 2016
Product - IIS 7.0, IIS 7.5, IIS 8.0, IIS 8.5, IIS 10.0
MOF file WebAdministration.mof

See Also

CollectionElement Class
HttpErrorsSection Class
Configuring Custom Error Messages
IIS Status Codes