CustomErrorCollection 类
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
表示 对象的集合 CustomError 。 此类不能被继承。
public ref class CustomErrorCollection sealed : System::Configuration::ConfigurationElementCollection
[System.Configuration.ConfigurationCollection(typeof(System.Web.Configuration.CustomError), AddItemName="error", CollectionType=System.Configuration.ConfigurationElementCollectionType.BasicMap)]
public sealed class CustomErrorCollection : System.Configuration.ConfigurationElementCollection
[<System.Configuration.ConfigurationCollection(typeof(System.Web.Configuration.CustomError), AddItemName="error", CollectionType=System.Configuration.ConfigurationElementCollectionType.BasicMap)>]
type CustomErrorCollection = class
inherit ConfigurationElementCollection
Public NotInheritable Class CustomErrorCollection
Inherits ConfigurationElementCollection
- 继承
- 属性
示例
此示例演示如何以声明方式为 error 节的 customErrors 元素指定值,该元素也可以作为集合的 CustomErrorCollection 元素进行访问。
以下配置文件示例演示如何以声明方式为 error 元素指定值。
<customErrors mode="RemoteOnly"
defaultRedirect="customerror.htm">
<error statusCode="404" redirect="customerror404.htm"/>
</customErrors>
下面的代码示例演示如何使用该 CustomErrorCollection 类。
// 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
注解
该 CustomErrorCollection 类型允许访问 error section 元素集合的 customErrors 元素。
它属于包含
构造函数
| 名称 | 说明 |
|---|---|
| CustomErrorCollection() |
初始化 CustomErrorCollection 类的新实例。 |
属性
方法
显式接口实现
| 名称 | 说明 |
|---|---|
| ICollection.CopyTo(Array, Int32) |
将 ConfigurationElementCollection 复制到数组。 (继承自 ConfigurationElementCollection) |
扩展方法
| 名称 | 说明 |
|---|---|
| AsParallel(IEnumerable) |
启用查询的并行化。 |
| AsQueryable(IEnumerable) |
将 IEnumerable 转换为 IQueryable。 |
| Cast<TResult>(IEnumerable) |
将 IEnumerable 的元素强制转换为指定类型。 |
| OfType<TResult>(IEnumerable) |
根据指定类型筛选 IEnumerable 的元素。 |