PassionateDeveloper
PassionateDeveloper

Reputation: 15138

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?

Upvotes: 0

Views: 131

Answers (1)

Darin Dimitrov
Darin Dimitrov

Reputation: 1038990

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.

Upvotes: 2

Related Questions