Jignesh Kumar

Jignesh Kumar

  • 32
  • 37.3k
  • 2.8m

How to handle exception in MVC when SQL service is down?

Dec 28 2019 3:30 AM
There is scenario where I need to handle exception : Web application wich has custom Attribute implemented but in this aatribute constructor it self hitting database and try to bring resource from database but due to service down it throws error "A network-related or instance-specific error occurred while establishing a connection to SQL Server".I need to handle this error in Application_error at Global.asax file but due to this eception I am getting response and request as null.due to Request and Response both are null so not able to redirect to custome pageI need to redirect to custom error page when sql service is down.I have google it most of article but all have used handleerror attribute but here my case route table itself is not initialized due to above scenario throws execption in constructor of custom attibute.

Answers (1)