I was doing some research this week around the publishing wizard for ASP.NET and stumbled across a MSDN Library article that made mention of something I head never heard of before: the App_offline.htm file. Apparently, this is a feature introduced in .NET 2.0 where if you simply create a file named App_offline.htm and place that in the root of your ASP.NET application then all requests to the application will be immediately redirected to this page. This provides a nice, easy, clean way to let end users know you are updating your site, or making changes.
I’d just never heard of this before. ScottGu mentioned it several times on his blog (here’s a post from 2006 on the subject - I point out this particular post because it indicates you must send back more than 512 bytes of data otherwise IE6 will show a “friendly error” instead of the contents of the App_offline.htm file since the server also doesn’t return a 200 HTTP status code). Here’s a quote from his blog:
“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.”
That’s just an awesome feature. While you could probably pull off the same thing on your own with a little effort, it’s very cool that this is just baked right into the platform. Very, very cool.
So, be honest, was I the only one who hadn’t heard about this yet?