Partilhar via


Easiest way to take your web site offline (IIS 6.0 or IIS 7.5 with .NET 4.0)

If you are running your application within a .NET 4.0 application pool (IIS 7.0 or IIS 7.5) or your web site is configured as an ASP.NET 4.0 web site (IIS 6.0) and would like to show your clients an "under maintenance" page for a limited time, the easiest way is to put a file named app_offline.htm in your web site's root folder. Then your application will be taking offline and the clients will be served with app_offline.htm page whatever their requests are.

When you are done with maintenance, just remove or rename the file and everything goes back to normal.

Applies To:

IIS 6.0, IIS 7.5 with .NET 4.0

Update:

As commented, this also works in ASP.NET 2.0 / 3.5.

--
AMB

Comments

  • Anonymous
    February 03, 2012
    Just keep in mind that if you bump the server during the maintenance, they'll still get a 404
  • Anonymous
    February 03, 2012
    Also works with .NET 2.0 and 3.5.
  • Anonymous
    February 19, 2012
    Wow.. very cool feature.Thanks for the trick.
  • Anonymous
    February 19, 2012
    Just wondering if this is an IIS feature or the ASP.NET feature.I have a .NET 1.1 website running on IIS 7.0. Is this gonna work.Will test it tomorrow on my test servers and will revert. Hope it works.
  • Anonymous
    February 19, 2012
    @arun.passioniway - This is an ASP.NET feature and it was introduced in ASP.NET 2.0 first so it won't work in ASP.NET 1.1 unfortunately.
  • Anonymous
    September 25, 2013
    It is important to know that the file has to have more than 512 bytes of data otherwise a standard 404 error message is returned. I had to add additional text (I used comments) which then resolved the problem.
  • Anonymous
    March 26, 2014
    Worked without 512 byte size constraint on 4.0
  • Anonymous
    April 23, 2014
    Works for me. A nice easy way to dynamically stop and start access to the site.Thanks for the tip.
  • Anonymous
    May 15, 2014
    If I access  https://sitename/VirtualDirectoryName/, the app_offline.htm is displayed.However, if I access a html page directly, It's not displaying the app_offline.htm.Can someone help me?
  • Anonymous
    June 03, 2014
    @ Karla R ==> unfortunately that is an ASP.NET feature which does not apply to static files.
  • Anonymous
    July 18, 2016
    The comment has been removed
  • Anonymous
    October 10, 2016
    This is really nice feature.Unfortunately looks like IE is only considering the Return code 404 and it present to the customer a default Page Not Found.Any idea of how to solve that?
    • Anonymous
      October 24, 2016
      @Marco hello, can you please elaborate your issue a bit? The size of the app_offline.htm should be larger than a limit, if I remember correctly it should be at least a few KBs, otherwise it will not work as expected so maybe it is the issue you are describing.
  • Anonymous
    February 21, 2019
    Still works in IIS 10, just as a note