App_Offline, IIS Redirection, and the wonders of online documentation. (posted by Arturo)

By now, you’re probably aware that ASP.NET 2.0 allows you to place a specially named file in your web root, which takes down your application to allow you to make updates to your site without generating strange errors for your users if they hit the page in the middle of your prop. (If you hadn’t heard, then you can read all about it here)

I had originally intended this blog to sell you on the fact that this little trick, had the added benefit of allowing you to provide a much smarter redirect than IIS can provide for your application in the case of a URL change. However, as I did a little fact checking, apparently IIS does allow quite a bit of flexibility when setting up redirects.

There are a number of wildcards and flags you can provide when setting up the redirect URL the most interesting of which being the $Q flag, which allows you to carry over any query string information to the redirected URL. You can get more details here. (Note that while the documentation referenced is for IIS 6.0, the same flags are supported in IIS 5.0)

While this little tidbit of information does shoot to hell my initial thesis, it did allow me to find some little caveats of the App_Offline feature which you may want to be aware of.


  • The default document of your site must still be present on the virtual directory. I.E you can’t simply have an App_Offline.htm file up on your server and expect it to be served. You still need to tell IIS that you want ASP.NET to handle this request. An empty default.aspx file is enough to do the trick.
  • Your App_Offline.htm file must contain proper , and tags with content, to be served. I can’t really say why that is, but I couldn’t get it to work otherwise.

It’s amazing the information you’ll run into when you actually read the documentation of the product you’re working with. Whoda thunk it.