asp.net.ph

Skip Navigation Links

<customErrors> Section

ASP.NET Syntax   ASP.NET Configuration Sections


Provides information about custom error messages for an ASP.NET application.

<customErrors 
   defaultRedirect = "url"
   mode = "On | Off | RemoteOnly">
   <error
      statusCode = "statuscode"
      redirect = "url" />
</customErrors>

The <customErrors> tag supports two attributes and one subtag.

Attribute Option Description
defaultRedirect     Specifies the default URL to direct a browser to if an error occurs.
mode     Specifies whether custom errors are enabled, disabled, or shown only to remote clients.
    On Specifies that custom errors are enabled.
    Off Specifies that custom errors are disabled.
    RemoteOnly Specifies that custom errors are shown only to remote clients.

Subtag Description
<error> The error subtag can appear multiple times. Each appearance defines one custom error condition.

The <error> tag supports two attributes.

Attribute Description
statusCode Specifies the error status code that redirects a browser to a nondefault error page.
redirect Specifies the URL to redirect the browser to if an error occurs.

Syntax Example

The following example specifies the error handling pages to use for an ASP.NET application.

<configuration>
   <system.web>
      <customErrors defaultRedirect = "genericerror.html"
         mode = "RemoteOnly">
         <error statusCode = "500"
            redirect = "InternalError.html" />
      </customErrors>
   </system.web>
</configuration>
See Also

ASP.NET Configuration   CustomErrorsSection Class   CustomErrorsMode Enumeration



© 2025 Reynald Nuñez and asp.net.ph. All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note