How to disable ASP.NET site if critical services are unavailable

How are you going to host the site offline if the database is down or the database adapter is missing / failed to load / etc?

I ask in the context of ASP.NET MVC 3, but this can be applied to any ASP.NET site.

Say, somewhere around App_Start you are loading an assembly to access data, and this is missing and / or something else fails. In this case, the site cannot actually function.

I am looking for a decent / elegant way to host a site in maintenance mode just like App_Offline.htm works.

+5
source share
2 answers
catch (ReallyBadException ex) {
    Utilities.EmailAdministrator();
    File.Copy(@"c:\templates\App_Offline.htm", @"c:\path\to\website\App_Offline.htm");
}
+6

, ( , ASP.NET), .

+1

All Articles