How to catch a "No database available"-error in ASP.Net correctly?
I am on my way to my first bigger project in ASP.Net.
I want to know how to catch, and where to catch, the error when the database is not available. Let's say a community site in which you have, from beginning开发者_开发百科 to end, lots of database queries. Maybe a few outsourced in other helper classes, some in the DataAccess-Layer and maybe 1 or 2 directly from Front-End.
How and where can it be caught in a good and consistent way?
This might depend on the actionsyou would like to take when this exception occurs but a good place is to use the global error handler Application_Error
(in global.asax) which is called every time an unhandled exception is thrown and where you log the error and redirect the user to some page.
精彩评论