In a deployed application, you should use the On or RemoteOnly error mode. Any errors in your application should be dealt with through error-handling code, which can then present a helpful and user-oriented message (rather than the developer-oriented code details in ASP.NET’s rich error messages).
However, you can’t catch every possible error in an ASP.NET application. For example, a hardware failure could occur spontaneously in the middle of an ordinary code statement that could not normally cause an error. More commonly, the user might encounter an HTTP error by requesting a page that doesn’t exist. ASP.NET allows you to handle these problems with custom error pages.
You can implement custom error pages in two ways. You can create a single generic error page and configure ASP.NET to use it by modifying the web.config file as shown here:
<configuration>
<system.web>
<customErrors mode="RemoteOnly" defaultRedirect="DefaultError.aspx" />
</system.web>
</configuration>
ASP.NET will now exhibit the following behavior:
• If ASP.NET encounters an HTTP error while serving the request, it will forward the user to the DefaultError.aspx web page.
• If ASP.NET encounters an unhandled application error and the mode is set to On , it will forward the user to the DefaultError.aspx. Remote users will never see the generic ASP.NET error page.
• If ASP.NET encounters an unhandled application error and the mode is set to Off, it will display the ASP.NET error page instead.
• If ASP.NET encounters an unhandled application error and the mode is set to RemoteOnly, the behavior depends on where the request is originating from. If it’s a local request being made from the same computer, you’ll get the ASP.NET error page with the diagnostic information. Otherwise, you’ll see the DefaultError.aspx page.
No comments:
Write comments