开发者

redirect user to error page if database is down

开发者 https://www.devze.com 2023-02-15 04:02 出处:网络
I have implemented global error handling in my global.asax file to handle any exceptions that bubble all the ways up the stack. My web application connects to sql server databases along with an oracle

I have implemented global error handling in my global.asax file to handle any exceptions that bubble all the ways up the stack. My web application connects to sql server databases along with an oracle database. In my error handler I handle any exceptions that occur by logging them and redirecting the user to a custom error page.

What I need to implement is that if either of the databases (oracle or sql server) are not available, server down开发者_如何学Go etc, then redirect the user to another error page.

My thoughts on doing this was to examine the exception that bubbles up to the global.asax page and if an oracle or sql exception, redirect to this other error page.

Is there any other way I could do what I need to do cleaner? Or a better solution? Apart from the exception being of type SqlException or OracleException are there any other properties in the exception I should examine that signals the db is down, if I go with my approach?

Thanks


A smart way would be to attempt a connection with the database. For oracle you can also do something equivalant of a tnsping which should let you know that he db is up or down/ listener is up or down etc.

0

精彩评论

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