开发者

How to put ASP.NET site offline if critical services are not available

开发者 https://www.devze.com 2023-03-01 23:14 出处:网络
How would you go about placing the site off-line if the database is down or the database adapter is missing / failed to load / etc.?

How would you go about placing the site off-line if the database is down or the database adapter is missing / failed to load / etc.?

I am asking in the context of ASP.NET MVC 3 but this can apply for any ASP.NET site.

Let's say somewhere around App_Start you load an assembly for data access and this is missing and/or something else fails. In this case the site can't actually function.

I'm looking for a decent/elegant way to place the site in "Maintenance mode" just like App_Offline.htm wo开发者_运维知识库rks.


catch (ReallyBadException ex) {
    Utilities.EmailAdministrator();
    File.Copy(@"c:\templates\App_Offline.htm", @"c:\path\to\website\App_Offline.htm");
}


Check out Circuit breaker pattern

Maybe too general for you (i am not sure if you are looking for conceptual solution or ASP.NET specific) but it can help you.

0

精彩评论

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

关注公众号