How to do maintenance work on a live website?

When you first launch a website, you’re not too concerned whether the site is down or having problems because initially you have few or no visitors at all. So you’ll not be upsetting anyone if the website is down but that is a huge problem is your website is established and you need to perform updates or maintenance work to your site. People might be accessing your site and they could be put off if it does not respond properly or it shows errors.

Steps to follow to update a live website

  1. The first thing that you need to do is point the live website at a different directory (web app).
  2. Then you need to ftp your new files to the directory of your live site
  3. And lastly you’ll need to point the live site back to the original directory

This sounds really easy but there are things to take into consideration. While your site is down, your first priority is to inform your visitors that you’re performing maintenance work on the site. You could put up a page with a nice little message for that. What I’ve done is create a web app specifically for that purpose. It has an HttpModule that intercepts all incoming requests and redirects to a maintenance page. So no matter which webpage of my website people are trying to view during the maintenance period, they will be shown the maintenance page.

Now that’s all good but you need to inform search engine crawlers as well, otherwise they might think that your page does not exist or have been modified and that could result in either your pages being deindexed or dropped in rankings. To ensure that bots know your maintaining your website, you’ll need to respond with a 503 http status code. This informs them that the downtime is temporary and your site will be back up soon. In my case, this is handled in my httpmodule which issues the 503 status code.

Prevent IIS from showing a default error page

My maintenance web app was tested on my Windows 7 laptop and everything worked fine here but when I uploaded the site content to my server, my custom maintenance page did not show up and instead I was presented with an ugly default error page. The http status code was 503 (which is correct) but the page itself came from IIS and was not the one I designed. To solve this problem, I had to add Response.TrySkipIisCustomErrors = true in my httpmodule to prevent IIS from intercepting the request ( Here’s the code:

private void Application_BeginRequest(Object source, EventArgs e)
HttpApplication application = (HttpApplication)source;
HttpContext context = application.Context;

context.Response.TrySkipIisCustomErrors = true;
context.Response.Status = "503 Service Unavailable";
context.Response.StatusCode = 503;
context.Server.Transfer("~/Maintenance.aspx", false);

The use of the app_offline.htm

When I first heard of app_offline.htm, I was really excited because it was such a painless way to go into maintenance mode. You just add this file in your website contents and bang, you are in maintenance mode. All calls are intercepted and the http status code becomes 503. You can put a nice little message in that html file for your visitors and design it beautifully. There are a couple of problems with this approach though:

  • First, your web app needs to be in a stable state. If your modifying dll in your bin or web.config, that’s all going to render your live website into an unstable application and app_offline.htm will be pretty much useless and your visitors or search crawlers will not be happy. I had this problem as my site is precompiled and changing one file means that the whole app needs to be rechanged. So in the end, I had to write the http module to overcome this problem.
  • Second, you cannot insert images in the app_offline.htm because relative paths will not work. The workaround is to have the image hosted on another server (maybe a free one) and have it embedded in the html (
  • Third, you might need to have enough content in the html file (it needs to be a certain size) for it to display properly across all browsers. So if you have just a one line sentence, some people may be presented with an ugly default error document.

Maintenance work on a website is inevitable but as long as you have a process in place, everything should work out fine. Just remember to maintain your website when you have the least number of visitors.