Dave Knipper Was Here

Responding with a 503 HTTP Status Code from an HTML Page (With Some Help from ASP.NET)

I'm currently working for a client doing SEO work. The clients web application is using ASP.NET web forms. They wanted a setup that if there are issues with site (i,e, bad status codes such as 500s) they wanted to deliver an HTML page to the client saying some sort of generic error (e.g. "Sorry something broke!")

The IIS Server was setup to send all 500-type errors to an HTML page in the root called ~/500.html. The problem is that this page was sent to the client after the redirect with a response code of 200. Delivering 200s on a server error causes penalties in Google. My guess is that Google sees text like "Sorry, Error!", and a status code of 200, and says "Sorry... you fail... your getting dinged." The client basically wanted the same behavior, but with 503 status codes delivered instead of 200s. The also wanted to be able change 500.html whenever they wanted without any developer/IIS admin intervention. Here's how I handled it with some simple changes to the web.config and the addition of an ASP.NET Web Forms HTTP Handler:

1. Setup your HTML file. I'm going to call this ~/500.html. 2. Write an HTTP Handler that will read the file, and deliver it with a 503 status code. I'll call this ~/Custom503.ashx. 3. Setup the web.config. The web.config sees that there was an attempted response of ~/500.html from IIS. It then circumvents it and re-routes to the handler. The handler reads ~/500.html and streams it back to client with a 503 response code. PLEASE NOTE. If you include images or .css files within your page, those elements will deliver 200s. I'm not sure if there is a penalty for this from Google, but I would personally go with inline styles and avoid adding images to your .html file