Share via


Friendly HTTP Error Pages

Internet Explorer 5 and later will show a  “Friendly” HTTP Error page if the server returns certain HTTP Error status codes with a short message body. The intent is to replace a terse server message like this one:

Terse server error page for 404s

...with a page which may be slightly more helpful to the average user, like this one:

IE Friendly Error page for 404s

Unfortunately, IE's logic isn't smart enough to detect that, say, the response was a tiny HTML page with a META Refresh pointed at a different page, meaning that the META Refresh won't work until you pad the HTML response with enough text to be deemed "non-terse."

A common question from web developers is: What makes IE decide to show a friendly error page?

The answer is that the server’s response must meet two criteria:

  1. The HTTP Status code must be [400, 403, 404, 405, 406, 408, 409, 410, 500, 501, 505]
  2. The HTTP Response body’s byte length must be shorter than a threshold value

If the server’s response meets both criteria, then IE will show its own Friendly HTTP Error page instead of the server’s terse response.

The byte length thresholds are stored in the registry in HKEY_LOCAL_MACHINE under the subkey \SOFTWARE\Microsoft\Internet Explorer\Main\ErrorThresholds. The default threshold is 256 bytes for the response codes [403, 405, 410] and 512 bytes for response codes [400, 404, 406, 408, 409, 500, 501, 505]. If the registry entry is missing for one of the status codes, its threshold defaults to 512 bytes.

I wrote a simple script which allows you to test IE’s Friendly HTTP Error pages using Meddler.

The next most common question is: How do I prevent IE from showing the friendly error page?

If a user wants to prevent display of all Friendly HTTP Error pages, they can untick an option in the Internet Control Panel's Advanced tab, then restart IE. Of course, only the Friendly HTTP Error pages can be disabled in this way; other Friendly Error pages (like the DNS Lookup error or TCP/IP Connection failure page) cannot be disabled because IE has no other content from the server to display instead.

Internet Control Panel Advanced Option for Show Friendly Errors

Of course, it is impractical (and not necessarily desirable) to reconfigure IE on all client machines, so most servers that wish to ensure that users will see a given HTTP error message will pad the response with spaces or other characters until the response body length exceeds 512 bytes. For instance, Fiddler’s FailSession method contains the following code:

 if (iStatusCode >= 400) 
 { 
     if (strErrorBody.Length < 512) strErrorBody = strErrorBody.PadRight(512, ' ');
 }

...to ensure that any returned error message can be read by the user.

Obviously, if you’re going to prevent the display of the friendly error page, you’re strongly encouraged to provide a more friendly error page than the default; simply disabling the friendly error message without providing a better one isn’t very polite.

 

-Eric