Important Notice from AspDotNetStorefront
It is with dismay that we report that we have been forced, through the action of hackers, to shut off write-access to this forum. We are keen to leave the wealth of material available to you for research. We have opened a new forum from which our community of users can seek help, support and advice from us and from each other. To post a new question to our community, please visit: http://forums.vortx.com
Results 1 to 2 of 2

Thread: Database Error Catch and Redirect

  1. #1
    MudDiver is offline Member
    Join Date
    May 2009
    Posts
    44

    Default Database Error Catch and Redirect

    I had an issue the other day where my SQL server went offline and the website displayed an ugly error page. On sites I have written in the past I would put a catch on either the first database call or do a specific database call at page load to redirect to a sitedown.htm page if the database connection failed.

    Where would the best place be in the code for me to write such a method? I have tried it at the page level and in the template.ascx file but that doesn't catch the error. I assume that it is somewhere in the skinbase or is it higher up?

    Thank you.
    Jason Giles
    IT Manager / Web Services
    WTS Media
    www.wtsmedia.com

  2. #2
    MudDiver is offline Member
    Join Date
    May 2009
    Posts
    44

    Default

    Ok, I didn't think this all the way through. So just in case anyone else has a brain freeze and is looking to do this it is real simple. In classic .asp I would confirm the database connection and redirect if there was a problem. In asp.net I just set the defaultRedirect="sitedown.htm" in the web.Config in the CustomErrors section. I also had the 404 redirect that goes to the PageNotFound.aspx page.

    I don't know why that didn't occur to me when i posted that this morning.. I guess I was just thinking back to how I used to do it back with classic .asp.
    Jason Giles
    IT Manager / Web Services
    WTS Media
    www.wtsmedia.com