开发者

How to catch a "No database available"-error in ASP.Net correctly?

开发者 https://www.devze.com 2023-01-28 03:22 出处:网络
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, fro

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消