
444
|
Chapter 20: web.config Reference
This is the Title of the Book, eMatter Edition
Copyright © 2008 O’Reilly & Associates, Inc. All rights reserved.
Specifies one or more pages to which users should be redirected if an unhandled
exception is detected in an ASP.NET application. A default error page can be
specified, as well as one or more error pages for specific HTTP error codes.
Scope
Any
Attributes
defaultRedirect
Specifies the URL of the page to which all errors should be redirected when
no specific error page is configured for the HTTP status code of the error.
This attribute is optional.
mode
Specifies the custom errors mode. Valid values are
Off, On, and RemoteOnly.
Off disables custom error handling, On enables custom error pages for both
local and remote requests.
RemoteOnly enables custom error pages for remote
requests, while sending detailed error messages for local requests. This
attribute is required.
Child Elements
<error>
Example
The example configures a default page to be displayed to remote clients when an
unhandled exception is encountered:
<configuration>
<system.web>
<customErrors
defaultRedirect="Error.aspx" />
</system.web>
</configuration>
Notes
If you set the mode attribute to RemoteOnly, you will only be able to see detailed
error information from the local machine on which the pages are running. Remote
requests will return the custom error page (if any) configured for the status