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


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


Comments (14)
  1. Sean says:

    Just keep in mind that if you bump the server during the maintenance, they'll still get a 404

  2. RichardDeeming says:

    Also works with .NET 2.0 and 3.5.

  3. Wow.. very cool feature.

    Thanks for the trick.

  4. 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.

  5. @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.

  6. Bob says:

    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.

  7. .Net says:

    Worked without 512 byte size constraint on 4.0

  8. Mark H says:

    Works for me. A nice easy way to dynamically stop and start access to the site.

    Thanks for the tip.

  9. Karla R says:

    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?

  10. @ Karla R ==> unfortunately that is an ASP.NET feature which does not apply to static files.

  11. Filipe says:

    Thanks crazy Microsoft for Visual Studio to put this file on error after publish a site, and don’t remove after. So, loose almost all my life to understand that the error HTTP 503 was from this app_offline.html.

  12. Marco Casula says:

    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?

    1. @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.

  13. spikel46 says:

    Still works in IIS 10, just as a note

Comments are closed.

Skip to main content