CustomErrorsSection 类
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
配置 ASP.NET 自定义错误。 此类不能被继承。
public ref class CustomErrorsSection sealed : System::Configuration::ConfigurationSection
public sealed class CustomErrorsSection : System.Configuration.ConfigurationSection
type CustomErrorsSection = class
inherit ConfigurationSection
Public NotInheritable Class CustomErrorsSection
Inherits ConfigurationSection
- 继承
示例
此示例演示如何以声明方式为 customErrors 节的多个属性指定值,这些属性也可以作为 类的成员 CustomErrorsSection 进行访问。
以下配置文件示例演示如何以声明方式为 customErrors
节指定值。
<customErrors mode="RemoteOnly"
defaultRedirect="customerror.htm">
<error statusCode="404" redirect="customerror404.htm"/>
</customErrors>
下面的示例演示如何使用 CustomErrorsSection 类。
// Get the Web application configuration.
System.Configuration.Configuration configuration =
WebConfigurationManager.OpenWebConfiguration(
"/aspnetTest");
// Get the section.
CustomErrorsSection customErrorsSection =
(CustomErrorsSection)configuration.GetSection(
"system.web/customErrors");
// Get the collection
CustomErrorCollection customErrorsCollection =
customErrorsSection.Errors;
' Get the Web application configuration.
Dim configuration _
As System.Configuration.Configuration = _
WebConfigurationManager.OpenWebConfiguration( _
"/aspnetTest")
' Get the section.
Dim customErrorsSection _
As CustomErrorsSection = _
CType(configuration.GetSection( _
"system.web/customErrors"), _
CustomErrorsSection)
' Get the collection
Dim customErrorsCollection _
As CustomErrorCollection = customErrorsSection.Errors
注解
CustomErrorsSection 类提供一种以编程方式访问和修改配置文件的 customErrors
节的方法。 此类型是包含 、 CustomErrorsMode和 CustomError 类型的组的CustomErrorCollection一部分。
注意
CustomErrorsSection可以根据值为 Everywhere的 section 属性AllowDefinition,从 配置文件的相关节读取和写入信息。
构造函数
CustomErrorsSection() |
使用默认设置初始化 CustomErrorsSection 类的新实例。 |