There’s a cool feature of ASP.NET 2.0 that allows you to quickly and easily take a site down for maintenance while sending users a friendly message. Just drop a file called app_offline.htm in the root of your site. However, there’s a little-known feature of IIS that can make this trickier than it seems. Scott Guthrie explains:
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.
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 (which personally I don’t think is super friendly <g>).
So if you use the app_offline.htm feature, you should make sure you have at least 512 bytes of content within it to make sure that your HTML (instead of IE’s friendly status message) shows up to your users. If you don’t want to have a lot of text show-up on the page, one trick you can use is to just add an html client-side comment with some bogus content to push it over 512 bytes.
Scott also includes an example, which demonstrates how you can use commented markup to push the file over the 512 byte mark, even if you don’t have enough stuff you really want to show. Of course, in the typical production app, with styles and other formatting, you’re probably never going to run into this. But it tripped me up in testing out the feature, so I’m glad Scott was ready with an explanation and a way to make it work consistently.