1. Normally sites are deployed in Web farm scenarios. If your app is also deployed in a web farm then it’s better to bring one server down update the code base there while all the user request would be served by the other servers in the farm. This way the downtime of the application would be almost zero.
2. If at all your application is deployed on a single server then either you need to face the downtime :) or temporarily create another virtual directory with the old code base. This Virtual directory would be functional till the time you update the actual directory with your latest code base. There would be some negligible amount of downtime here.
3. If you can’t create a new virtual directory for some reason! Then create a static page (“SiteDownForMaintanance.htm”) and based on a flag in your “web.config” redirect all request to this static page. Once the code base has been updated, change the Boolean flag in your “web.config” to false.
I am sure there might be other options to resolve this too. So I started (re)searching through the web to read how experts have handled similar situations in their projects. During one such (re)search I found about “App_offline.htm” concept in ASP.NET 2.0.
The concept seems to be really simple / cool. Let me explain it for those who haven’t heard about it.
1. We need to create an html page with name “App_offline.htm”. Put whatever junk content you want to display to your user during the application maintenance!
2. Now run any page in your application to see the content of “App_offline.htm” to be displayed.
3. Once you have done with your updates or maintenance remove this file from your project. That’s all.
Though I have read that “Excluding this file from project” is also enough it didn’t work for me. It worked only when I removed it from the project or renamed it to something else.
From ScottGu’s blog i came to know that
“The way app_offline.htm works is that you place this file in the root of the application. When ASP.NET sees it, it will shut-down the app-domain for the application (and not restart it for requests) and instead send back the contents of the App_offline.htm file in response to all new dynamic requests for the application. When you are done updating the site, just delete the file and it will come back online.”
Interesting isn’t it?
There is another point which I would like to bring to your notice. From ScottGu’s blog I came to know about this as well
“One thing I pointed out in the talk that you want to keep an eye on is a feature of IE6 called "Show Friendly Http Errors". This can be configured in the Tools->Internet Options->Advanced tab within IE, and is on by default with IE6. When this is on, and a server returns a non HTTP-200 status code with less than 512 bytes of content, IE will not show the returned HTML and instead substitutes its own generic status code message”
I am not sure whether he is wrong or in IE 6.0 SP2 they have changed it! because I created an “empty App_offline.htm” page and it worked. The Browser Version in my system is IE 6.0 SP2 and “Show Friendly Http Error Messages” is by default checked in it.
Technorati tags: ASP.NET, Scott Guthrie