Mondeo Posted December 28, 2006 Posted December 28, 2006 Is there any way I can redirect to an error provider page whenever any exceptions occur on my site - by that I mean any that are not caught by Try/Catch blocks Ideally i'd like a page called errorProvider.aspx which simply sends a copy of the execption to admin and displays a "sorry an error has occured" type message. How is this scenario usually implemented? Quote
MrPaul Posted December 28, 2006 Posted December 28, 2006 web.config and global.asax There are two steps here - displaying an error page to the user, and handling the exception and responding appropriately (logging the error, sending an email, etc). The error page can be set in the web.config file like so: <system.web> <customErrors mode="On" defaultRedirect="errorProvider.aspx"/> </system.web> When an error occurs, the user will be redirected to errorProvider.aspx. For the logging or emailing, you can implement this with a global.asax file, which is the successor to the global.asa file in ASP. This file contains code which can respond to application-level events, such as sessions starting and ending, requests starting and ending, and unhandled exceptions being thrown. The Application_Error event occurs when an unhandled exception occurs. This article explains enough to get you started. Good luck :cool: Quote Never trouble another for what you can do for yourself.
bri189a Posted January 7, 2007 Posted January 7, 2007 Just so you know, it's rarely mentioned, but between the method that threw the error and the global handler you can also override the Page OnError method so that you can handle errors for a page in a single location, sometimes you need something a little more fine grained than the global handler for a specific page. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.