Quickly put your ASP.NET web site on IIS to maintenance mode with the app_offline.htm file
Posted: (EET/GMT+2)
As the summer approaches, many web sites are brought down for maintenance work. With ASP.NET web applications, this usually isn't an issue because the files are generally not locked. But, if the site is large, it might well take some time while you update the files within the site.
IIS has for a long time already supported a little-known file called "app_offline.htm". This file, when placed at the root (virtual) folder of your application, instructs IIS to stop serving any request to that application to be redirected to this file.
Note that the file is static: there's no server-side processing possibility, and even, all references to CSS files and images within that application stop working. If you put a friendly message to that file saying that your site is under maintenance, you have same breathing space to complete your task at hand.
Once you are done, you can simply delete that file (while saving it for later, I'd suggest), and your site is again live.
Two notes on this file: firstly, some browsers – especially IE – might interpret the resulting file as an error message if it's too small. Make sure your file is over 512 bytes; you could easily add some nice CSS and/or HTML comments to do the trick.
Secondly, there often seems to be a question about images. Since IIS will stop redirect all requests within that application to your static HTML file, you cannot point to images within the same application. You can use in-line images (base64 encoded data URLs), but personally, I find it much easier to simply host the images on another server/site/application, and simply point to those from the HTML code. Problem solved.
Happy hacking!
Keywords: IIS maintenance file, how to indicate your ASP.NET web application is under maintenance, mark your web application to be under maintenance.