Base solution for your next web application
Open Closed

Redirect to error page when no db or server is found #3788


User avatar
0
carelearning created

if the database or database server specified in the connection strings of the web.config file cannot be found, we would like to redirect to a more graceful error page. The error will first appear for us in global.asax.cs > Session_Start > RestoreUserLanguage.

I can trap the error by doing something like this inside a try-catch

SqlConnection connection =
                    new SqlConnection(ConfigurationManager.ConnectionStrings["Tenant"].ConnectionString);
                connection.Open();

: if this fails, then I would like to redirect/transsfer/execute something to get to a Error/NoDb. I have an ErrorController.cs with this view, but cannot figure out if it is possible to get there because the database does not exist. Is this possible with ABP.Net Zero?


1 Answer(s)
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @careLearning,

    There is nothing special to ABP Framework and AspNet Zero about this. You can try to use ABP's global exception event <a class="postlink" href="https://aspnetboilerplate.com/Pages/Documents/Handling-Exceptions#DocExceptionEvent">https://aspnetboilerplate.com/Pages/Doc ... ptionEvent</a> or you can do it just like in another ASP.NET project.

    Thanks.