Recent Posts

Sunday, July 13, 2008

Simple way of Error Handling in ASP.Net

To Redirect your page to more appropriate error page for the Client

Go to Web.config file and add redirection location in customErrors tag
For example:

"<"customErrors defaultRedirect="http://hostName/applicationName/errorStatus.htm" mode="On" "/>"
"
Although you can reference a default error page in the value of the defaultRedirect
attribute in the section, you can also specify a particular page to
redirect to based on the HTTP error code that is raised.
The child element allows for this option.

For example:

"<"customErrors defaultRedirect="http://hostName/applicationName/errorStatus.htm" mode="On" "/>"
"<"error statusCode="404" redirect="filenotfound.htm" "/>"


"<"customErrors : section includes a mode attribute that is set to On by default.

The mode attribute includes the following settings:
• On: Unhandled exceptions redirect the user to the specified defaultRedirect page. This mode is used mainly in production.

• Off: Users receive the exception information and are not redirected to the defaultRedirect page. This mode is used mainly in development.
• RemoteOnly: Only users who access the site on the local computer (by using localhost) receive the exception information. All other users are redirected to the defaultRedirect page. This mode is used mainly for debugging.

"

Related Posts by Categories




No comments:

Post a Comment