How to manage unhandled Exception?

 Posted by Bharathi Cherukuri on 2/2/2012 | Category: ASP.NET Interview questions | Views: 2858 | Points: 40

You can manage unhandled exception by configuring the <customErrors> element in web.config file.
It has 2 attributes:

Mode Attribute:It specifies how the custom error page should be displayed.
It has 3 values:
on - Displays custom error pages at both the local and remote client.
off - Disables custom error pages at both the local and remote client.
RemoteOnly - Displays custom error pages only at the remote client as it displays default error page for local machine.This is default setting in web.config file.
defaultRedirect:It is an optional attribute to specify the custom error page to be displayedwhen an error occurs.
The custom error page is displayed based on http error statusCode using error element inside the customError element.
If none of the specific statusCode matches with it, it will redirect to defaultRedirect page.


<customErrors mode="RemoteOnly" defaultRedirect="~/DefaultErrorPage.htm">

<error statusCode="103" redirect="NoAccess.htm"/>
<error statusCode="104" redirect="FileNotFound.htm"/>

Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Login to post response