Page 115 - DCAP312_WEB_TECHNOLOGIES_II
P. 115
Unit 6: Error Handling
This section lets you specify the error page to which the user should be redirected to when an Notes
unhandled exception propagates in the application level. This section specifies error pages for
both default errors as well as the HTTP status code errors.
<customErrors mode= “On” defaultRedirect= “/WebTest/ErrorPages/AppError.html”>
<error statusCode= “404” redirect= “/WebTest/ErrorPages/404.html” />
</customErrors>
6.1.2 Custom Error Handling in ASP.NET
To customize the default error page, one will have to change the default configuration settings
of the application. There are three error modes in which an ASP.Net application can work:
• Off Mode
• On Mode
• Remote Only Mode
The Error mode attribute determines whether or not an ASP.Net error message is displayed.
By default, the mode value is set to “Remote only”.
Off Mode
When the error attribute is set to “Off”, ASP.Net uses its default error page for both local and
remote users in case of an error.
On Mode
In case of “On” Mode, ASP.Net uses user-defined custom error page instead of its default error
page for both local and remote users. If a custom error page is not specified, ASP.Net shows
the error page describing how to enable remote viewing of errors.
Remote Only
ASP.Net error page is shown only to local users. Remote requests will first check the configuration
settings for the custom error page or finally show an IIS error.
<customErrors mode= “On” defaultRedirect= “/WebTest/ErrorPages/AppError.html”>
<error statusCode= “404” redirect= “/WebTest/ErrorPages/404.html” />
</customErrors>
The mode attribute specifies whether to show user-defined custom error pages or ASP.NET
error pages. Three values are supported for this attribute:
• Remote Only: Custom error pages are shown for all remote users. ASP.NET error pages
with rich error information are displayed only for local users.
• On: Custom error pages are always shown, unless one is not specified. When a custom
error page is not defined, an ASP.NET error page will be displayed which describes how
to enable remote viewing of errors.
• Off: Custom error pages are not shown. Instead, ASP.NET error pages will be displayed
always, which will have rich error information.
It is a bad idea to give users more in sequence than what is required. ASP.NET error pages
describe technical details that should not be exposed. Ideally, the mode attribute thus should
not be set to off.
LOVELY PROFESSIONAL UNIVERSITY 109