Bad Behavior error pages missing on IIS 7.0

December 14th, 2009 by Michael Hampton

Users of Bad Behavior on Microsoft Internet Information Server 7.0 may find that Bad Behavior’s error pages are not always displayed to spammers and malicious crawlers.

This behavior occurs because of a misfeature in IIS 7.0 where it serves custom error pages by default, overriding the error page generated by your web application. This is, of course, utterly broken behavior, and just one of many reasons you shouldn’t use IIS on Windows to serve your web site.

But some people still want to do it, so here is a workaround to allow Bad Behavior (not to mention every other web app you have) to display its error pages properly.

You will need to know your way around IIS already; I cannot give you any support for this.

You will need to modify your IIS configuration to set the web server httpErrors element to “passthrough”. An MSDN blog post from the IIS team explains how to set this property for an individual web site or for your entire server.

Not only does this provide a fix for Bad Behavior, it also fixes WordPress 404 pages, as well as numerous problems where a web application expects to generate its own error page. Of course, it’s utterly ridiculous that this requires a workaround and is not the default behavior, as it is with every other web server. But that’s one more reason not to use IIS.