Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Take an MVC web site offline and back online

I'm searching for a method to take a website offline with a message. I know about app_offline.htm, but I would like to do it programmatically.

Taking it offline is easy. I can generate app-offline.htm on root, but when I want web site to be back online it is not possible programmatically, because all services are down including images.

My project uses MVC (C#). For now I'm storing the site status in an SQL server database in a bit field.

like image 464
Erçin Dedeoğlu Avatar asked Jan 03 '14 19:01

Erçin Dedeoğlu


1 Answers

I find a method to doing it with global.asax but I would like to see other solutions...

    void Application_BeginRequest(object sender, EventArgs e)
    {
        if ((bool) Application["SiteOpenService"] == false)
        {
            if (!Request.IsLocal)
            {
                HttpContext.Current.RewritePath("/Site_Maintenance.htm");
            }
        }
    }

ref:

http://www.codeproject.com/Tips/219637/Put-the-website-in-Maintanance-Mode-Under-Construc

like image 197
Erçin Dedeoğlu Avatar answered Oct 03 '22 10:10

Erçin Dedeoğlu