How to handle downtime by sending all requests to one HTML page

I had a nice little Sunday planned today, but it was interrupted by the SharePoint911 uptime monitors telling me that our web server had pooped itself (technical term… trust me). Shane did some poking around and found that the hard drive had died… we have backups but bringing it back online is going to take a bit (our clients always come first!). We decided to temporarily put up a maintenance page until we can bring the site back completely. I had to do some GoogleBing’ing to find a simple way to funnel all of the web links that point to our various pages and blogs to one page telling people we are working on the problem.

Turns out the solution is actually pretty simple. Any ASP.NET 2 app (including SharePoint) can funnel all web traffic to one HTML page just by placing a file named app_offline.htm into the IIS web root. Here is more information on the technique:

Taking an ASP.NET 2.0 Application Offline

I did run into two gotcha’s:

  1. Make sure the file is over 512 bytes – Not sure why, but IIS thinks the file couldn’t possibly convey any useful information if its under that size and doesn’t use it.
  2. Loading images on the page can be challenging, they need to come from another web app or server or you need to do a lot of extra work to encode them. I didn’t bother with this method but you can search for it on the web if you want… I just hosted the images from our public Dropbox folder.