CustomError クラス
アセンブリ: System.Web (system.web.dll 内)


CustomError クラスを使用すると、構成ファイルの error セクションにプログラムからアクセスして変更できます。この型は、CustomErrorCollection、CustomErrorsMode、および CustomErrorsSection を含むグループの一部です。
![]() |
---|
カスタム エラーを定義すると、ASP.NET で、IIS などの基のサービスによって通常であれば発行される標準のエラーに、カスタム エラーが割り当てられます。たとえば、ステータス コード 404 に対してカスタム エラーを定義した場合、ASP.NET は、存在しない .aspx ページが参照されたときにこのエラーを発行します。カスタム エラーは、ASP.NET が処理できる要素に対してのみ発行されます。たとえば、存在しない .htm ページが参照された場合、IIS は標準 404 エラーを発行します。 |

この例では、customErrors セクションの複数の属性に対して、宣言によって値を指定する方法を示しています。これらの属性には、CustomError クラスのメンバとしてもアクセスできます。
次の構成ファイルの例では、customErrors セクションに対して、宣言によって値を指定する方法を示しています。
<customErrors mode="RemoteOnly" defaultRedirect="customerror.htm"> <error statusCode="404" redirect="customerror404.htm"/> </customErrors>
CustomError クラスを使用する方法を次のコード例に示します。
' Get the Web application configuration. Dim configuration _ As System.Configuration.Configuration = _ WebConfigurationManager.OpenWebConfiguration( _ "/aspnetTest") ' Get the section. Dim customErrors As CustomErrorsSection = _ CType(configuration.GetSection( _ "system.web/customErrors"), CustomErrorsSection) ' Get the collection. Dim customErrorsCollection _ As CustomErrorCollection = _ customErrors.Errors
// Get the Web application configuration. Configuration configuration = WebConfigurationManager.OpenWebConfiguration( "/aspnetTest"); // Get the section. CustomErrorsSection customErrors = (CustomErrorsSection)configuration.GetSection( "system.web/customErrors"); // Get the collection. CustomErrorCollection customErrorsCollection = customErrors.Errors;

System.Configuration.ConfigurationElement
System.Web.Configuration.CustomError


Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


- CustomError クラスのページへのリンク