Erik Porter's Blog

Life and Development at Microsoft and Other Technology Discussions

News

    Take Your ASP.NET 2.0 App Offline

    I just learned this a few minutes ago, but you can take an ASP.NET 2.0 application offline temporarily by uploading a file called App_Offline.htm.  It will spin down the appdomain and redirect all requests to that page.  Neato!

    Comments

    Ron Krauter said:

    Oh the coolness... Thanks!
    # October 5, 2005 10:52 PM

    Scott McCulloch said:

    Do you also need to set in the <httpRuntime> tag the attribute of enabled="false", this is what takes it down from the admin interface I think..
    # October 5, 2005 11:32 PM

    Jason Hoekstra said:

    Ahhh... the simple things in life really make me happy.
    # October 5, 2005 11:52 PM

    Bilal Haidar [MVP] said:

    Hi Erik:
    I tried to put such a page in the root directory of "File System" website and when I run the page, it will give me:
    "The page cannot be found",
    When i remove that page it works just fine and goes to my pages, is there any configuration that should be done? Does it work with File System websites or just http websites ?

    Regards'
    # October 7, 2005 3:40 AM

    TrackBack said:

    App_Offline.htm
    # October 7, 2005 11:44 AM

    Erik Porter said:

    Bilal, I don't know the answer for sure on that, but I believe that is correct. My question to you would be, why would you want to do this on a file system project on your local machine anyway. This feature is for your deployed application.
    # October 7, 2005 11:47 AM

    MaheshKumar.R said:

    Really awesome..it reduced my burden a lot..Thanks Guru :)
    Mahes,BLR,India
    # October 9, 2005 12:36 PM

    Sunish Abraham said:

    Hi Erik,

    Thanks for the information...I tried it out and it worked great! A colleague of mine tried this as well and somehome received a 404 (the App_offline.htm file was not empty)...so I wanted to make sure that this method was fool-proof. So I created a console application which used System.Net.WebRequest to access the website and flip-flop the App_offline.htm...it seems that I am receiving a 404 when I access the site programatically when the App_offline.htm exists. I would think I would have received a response which is similar to what I see in IE? Thanks for your assistance!

    Sunish
    # October 10, 2005 2:38 PM

    Danny said:

    hey how you turn online the aplication if in the asp.net web site admin tool u set "take application offline" by mistake

    i try to open up the asp.net web admin tool again but it shows me The resource cannot be found.
    Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly.

    and now every asp.net site is down.

    # October 11, 2005 4:07 AM

    Scott D. said:

    Is this only with the 2.0.50727 build and above? I tried it on our QA servers running 2.0.50215 and also received HTTP 404.
    # October 11, 2005 12:55 PM

    Scott McCulloch said:

    Danny, open up web.config and set enabled=true in the httpRuntime tag
    # October 14, 2005 7:53 AM

    Vineeth Raja said:

    Thanks for the neat tip.
    # October 14, 2005 11:38 AM

    Vista Discuss said:

    That works! Awesome.
    # November 6, 2006 1:17 AM

    Pravesh Khadka said:

    Ah ! This is what I am looking for. It will save me time and energy to create whole different aspx file and put logic on it.

    Appreciated,

    Pravesh

    # December 1, 2006 1:39 PM

    Matt said:

    I just put the following into my app_offline.htm file and I stopped getting the resource not found error.

    <html>

    <head>

    </head>

    <body>

    We are currently down for maintenance.

    </body>

    </html>

    # December 6, 2007 2:02 PM

    Rob Thornley said:

    If you get a 404 error, then pad your app_offline file with comments.  I think once it exceeds something like 512 bytes it starts working

    # March 11, 2008 7:14 AM

    crow12 said:

    si pero como podria ejecutar toda una aplicacion offline sin estar conectado a mi servidor y en un momento dado todos lo que realiza en mi aplicacion pueda actualizarse con lo que tengo en mi servidor

    # April 15, 2008 6:04 PM

    acl123 said:

    I found that I had to make sure a .NET aspx page and a web.config file were present in the same directory as the App_Offline.htm file, or it wouldn't work.

    # October 21, 2008 11:10 PM

    Poner offline una aplicacion ASP.NET – [ Web 2.0 | Tecnolog??a | Accesibilidad | Seguridad ] said:

    Pingback from  Poner offline una aplicacion ASP.NET &#8211; [ Web 2.0 | Tecnolog??a | Accesibilidad | Seguridad ]

    # October 22, 2011 10:41 AM

    Using Images in app_offline.htm | Random Brainworks said:

    Pingback from  Using Images in app_offline.htm | Random Brainworks

    # December 25, 2012 10:34 PM