CustomErrorsSection Class [IIS 7 and higher]
Configures ASP.NET custom error messages.
Syntax
class CustomErrorsSection : ConfigurationSectionWithCollection
Methods
The following table lists the methods exposed by the CustomErrorsSection class.
Name |
Description |
---|---|
(Inherited from ConfigurationSectionWithCollection.) |
|
(Inherited from ConfigurationSectionWithCollection.) |
|
(Inherited from ConfigurationSectionWithCollection.) |
|
(Inherited from ConfigurationSection.) |
|
(Inherited from ConfigurationSection.) |
|
(Inherited from ConfigurationSectionWithCollection.) |
|
(Inherited from ConfigurationSection.) |
|
(Inherited from ConfigurationSection.) |
|
(Inherited from ConfigurationSection.) |
Properties
The following table lists the properties exposed by the CustomErrorsSection class.
Name |
Description |
---|---|
CustomErrors |
An array of CustomError values that specify ASP.NET custom errors. |
DefaultRedirect |
A required, nonempty read/write string value that contains the default path of either an HTTP error message file or the URL of an error message. This value is inherited by the Redirect property of newly created CustomError objects. |
Location |
(Inherited from ConfigurationSection.) A key property. |
Mode |
A read/write sint32 enumeration that specifies whether custom or default error pages are shown locally or remotely. The possible values are listed later in the Remarks section. |
Path |
(Inherited from ConfigurationSection.) A key property. |
SectionInformation |
(Inherited from ConfigurationSection.) |
Subclasses
This class contains no subclasses.
Remarks
The custom errors represented by the CustomErrorsSection class are specific to ASP.NET and are in the <system.web> section of the Web.config file. Each of these errors is represented by an instance of the CustomError class.
The custom errors represented by the HttpErrorsSection class are related to IIS 7 and are in the <system.webServer> section of the ApplicationHost.config file. Each of these errors is represented by an instance of the HttpErrorElement class. The integration of ASP.NET with IIS in IIS 7 made this name change necessary.
The following table lists the possible values for the Mode property. The default is 0 (RemoteOnly).
Value |
Keyword |
Description |
---|---|---|
0 |
RemoteOnly |
The default ASP.NET error page is shown to local users. Remote users will receive a custom error page if one is defined. If no custom error page is defined for the error received, an IIS error page is shown. |
1 |
On |
A user-defined ASP.NET custom error page is shown for both local and remote users. |
2 |
Off |
The default ASP.NET error page is shown for both local and remote users. |
Example
The following example sets the DefaultRedirect property to "CustomError.htm" and the Mode property to On.
' Connect to the WMI WebAdministration namespace.
Set oWebAdmin = GetObject("winmgmts:root\WebAdministration")
' Get the custom errors section for the default Web site.
Set oSite = oWebAdmin.Get("Site.Name='Default Web Site'")
oSite.GetSection "CustomErrorsSection", oSection
' Set the default redirect page to CustomError.htm,
' and set the Mode property to On.
oSection.DefaultRedirect = "CustomError.htm"
oSection.Mode = 1
oSection.Put_
Inheritance Hierarchy
ConfigurationSectionWithCollection
CustomErrorsSection
Requirements
Type |
Description |
---|---|
Client |
Requires IIS 7 on Windows Vista. |
Server |
Requires IIS 7 on Windows Server 2008. |
Product |
IIS 7 |
MOF file |
WebAdministration.mof |
See Also
Reference
ConfigurationSectionWithCollection Class [IIS 7 and higher]
CustomError Class [IIS 7 and higher]