« Previous Next »

Answered Thread: Put website in "maintenance" mode

Last post 07-26-2009 7:07 PM by SLORider. 4 replies.

Average Rating Rate It (5)

RSS

Page 1 of 1 (5 items)

Sort Posts:

  • 11-03-2008, 10:33 AM

    Put website in "maintenance" mode

    Hi, I am a newbie at IIS admin stuff.

    My client wants me to build a script that shuts down the web site for maintenance. 

    We need to kill active sessions (without causing too much grief to the users connected)

    Then I need to put up a page that say under maintenance.

    I also need to redirect all the traffic to that page if the users are connecting using bookmarks.

    Then I obviously need a process to reverse this.  Any best practices on this problem and pre existing solutions?

  • 11-03-2008, 11:39 AM In reply to

    Re: Put website in "maintenance" mode

    Could it work if I included an asp script in all the pages of the site?  That page would check for a global server variable called "UnderMaintenance" or something like that.

    That check would be done on every page load, if true then redirect to Maintenance.asp... with auto refresh every 5 minutes to redirect to login page (or even back to previous page).

    Then all I'd have to script would be a change in the global server variables.

    When I do a change in that global.asa page, do I need to recycle the server for the changes to take place or it's automatic?

  • 11-04-2008, 5:42 PM In reply to

    Answered Re: Put website in "maintenance" mode

     If you have an ASP.NET web application site, and you place a text file named "app_offline.htm" in the root of the site, all requests to that website will redirect to that app_offline.htm file. Basically, if you need to take an entire ASP.NET site offline, you can place some nice message in that file. Then, any new requests to a URL, any URL, in that website will redirect to that file allowing you to do maintenance to the site, upgrades, or whatever. It is not really a redirect though. ASP.NET essentially shuts down the site, unloads it from the server, and stops processing any requests to that site. That is, until you delete the app_offline.htm file - then things will continue as normal and your ASP.NET site will load up and start serving requests again. 

    A super-cool side effect of this is that any files that are locked by the site, such as a database or other resources, are freed since the application domain has been unloaded from the server. This allows you to remove the locks from those files and replace them, without the need to do a full IISRESET, taking down other sites on the server. One thing to keep in mind with this file however, make sure you out enough content in it so it is larger than 512 bytes or IE will consider it a 404 and will display the 404 instead of the contents of your app_offline.htm file.

    http://weblogs.asp.net/pleloup/archive/2008/09/22/taking-an-asp-net-site-offline-with-a-message.aspx

  • 07-13-2009, 5:47 AM In reply to

    Re: Put website in "maintenance" mode

    Hi, the app_offline.htm is a nice feature, but appears to only do its job if the site is in a compilable state ... which surprised me (on IIS7/WS2008). I started changing my site, thinking that I was "protected" but as soon as I made an incompatible change to the config file, my users we're getting an error page instead of the app_offline.htm.

    What is really needed, is a way to still use (test, maintain) the site on the local machine, while all "remote" users get the app_offline.htm contents.

     Any ideas or tips!

     Thanks!

    Richard

  • 07-26-2009, 7:07 PM In reply to

    • SLORider
    • Top 500 Contributor
    • Joined on 11-25-2006, 10:11 PM
    • San Luis Obispo, CA USA
    • Posts 16

    Re: Put website in "maintenance" mode

     

    Hubert@Hubert-Associates.EU:
    What is really needed, is a way to still use (test, maintain) the site on the local machine, while all "remote" users get the app_offline.htm contents.

    Create a second web site to host the app_offline message using the same host header name, but keep it in a stopped state. To switch over, stop one and start the other. Then for testing, edit the binding on the first site to something like "test.example.com" and re-start it.

    Visit SLORider.com!
Page 1 of 1 (5 items)
Microsoft Communities