CustomError クラス
HTTP 状態コード エラーの ASP.NET カスタム エラー メッセージを指定します。
構文
class CustomError : CollectionElement
メソッド
このクラスにはメソッドが含まれていません。
プロパティ
次の表は、CustomError
クラスによって公開されるプロパティの一覧です。
名前 | 説明 |
---|---|
Redirect |
カスタム エラー メッセージを含むファイルまたは URL のパスを含む、必須の空でない読み取り/書き込みの string 値。 |
StatusCode |
HTTP エラー状態コードを指定する、必須の一意の読み取り/書き込みの sint32 値。 有効な値は 100 から 999 です。 キー プロパティ。 |
サブクラス
このクラスにはサブクラスが含まれていません。
解説
このクラスのインスタンスは、CustomErrorsSection クラスの CustomErrors
プロパティに含まれています。
CustomError
クラスによって表されるカスタム エラーは ASP.NET に固有であり、Web.config ファイルの <system.web>
セクションにあります。 HttpErrorElement クラスによって表されるカスタム エラーは IIS 7 に固有であり、ApplicationHost.config ファイルの <system.webServer>
セクションにあります。
例
次の例では、既定の Web サイトのカスタム エラー セクションにカスタム エラーを追加します。
' Connect to the WMI WebAdministration namespace.
Set oWebAdmin = GetObject("winmgmts:root\WebAdministration")
' Get the CustomError class object.
Set oCustomError = oWebAdmin.Get("CustomError")
' Create a new instance of the CustomError class.
Set oNewCustomError = oCustomError.SpawnInstance_
' Assign values to the StatusCode and Redirect properties.
oNewCustomError.StatusCode = 404
oNewCustomError.Redirect ="CustomPageNotFoundError.htm"
' Get the custom errors section for the default Web site.
Set oSite = oWebAdmin.Get("Site.Name='Default Web Site'")
oSite.GetSection "CustomErrorsSection", oCustomErrorsSection
' Call the CustomErrorsSection.Add method to add the custom error.
oCustomErrorsSection.Add "CustomErrors", oNewCustomError
継承階層
CustomError
要件
型 | 説明 |
---|---|
クライアント | - Windows Vista 上の IIS 7.0 - Windows 7 上の IIS 7.5 - Windows 8 上の IIS 8.0 - Windows 10 上の IIS 10.0 |
[サーバー] | - Windows Server 2008 上の IIS 7.0 - Windows Server 2008 R2 上の IIS 7.5 - Windows Server 2012 上の IIS 8.0 - Windows Server 2012 R2 上の IIS 8.5 - Windows Server 2016 上の IIS 10.0 |
Product | - IIS 7.0、IIS 7.5、IIS 8.0、IIS 8.5、IIS 10.0 |
MOF ファイル | WebAdministration.mof |
参照
CollectionElement クラス
CustomErrorsSection クラス
HttpErrorElement クラス
HttpErrorsSection クラス