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 類別 (Class) 提供以程式的方法,存取和修改組態檔的 customErrors 區段。 此類型是包含 CustomErrorCollection、 CustomErrorsMode和 CustomError 類型的群組的一部分。
注意
CustomErrorsSection可以根據其值為 Everywhere的 section 屬性AllowDefinition,從 組態檔的相關區段讀取和寫入資訊。
建構函式
| CustomErrorsSection() |
使用預設值初始化 CustomErrorsSection 類別的新執行個體。 |