Put website in "maintenance" mode [Answered]RSS

5 replies

Last post Nov 01, 2010 09:01 AM by dancriel

  • Put website in "maintenance" mode

    Nov 03, 2008 10:33 AM|NinjaRgRus|LINK

    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?

  • Re: Put website in "maintenance" mode

    Nov 03, 2008 11:39 AM|NinjaRgRus|LINK

    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?

  • Re: Put website in "maintenance" mode

    Nov 04, 2008 05:42 PM|KeithHutch|LINK

     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.


  • Re: Put website in "maintenance" mode

    Jul 13, 2009 05:47 AM|Hubert@Hubert-Associates.EU|LINK

    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!



    web site maintenance mode

  • Re: Put website in "maintenance" mode

    Jul 26, 2009 07:07 PM|SLORider|LINK



    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!
  • Re: Put website in "maintenance" mode

    Nov 01, 2010 09:01 AM|dancriel|LINK

    Follow up so I can google for this again if I need to - the above solution works but I also needed to send 404 and 403.1 errors to my "site is down for maintenance" html page.