I want to display a custom error page:
<!doctype html>
<html>
<head><title>400 Bad Request</title></head>
<body><h1>400 Bad Request</h1>
The grob must be in the frobber.
</body>
</html>
Unfortunately, Internet Explorer ignores the response sent by the HTTP server; hiding my page and showing their own:
How can I convince Internet Explorer to show the page the user was sent?
Edit Chrome began doing the same thing in 2008. People have asked for it to be fixed; but it's marked as won't fix.
And you can fix it using the same trick in the answer.
The solution is PADDING.
Microsoft notes in knowledge base article KB294807:
HOW TO: Turn Off the Internet Explorer 5.x and 6.x "Show Friendly HTTP Error Messages" Feature on the Server Side
...these "friendly" error messages are only displayed if the response that is sent to the client is less than or equal to a specified threshold. For example, to see the exact text of an HTTP 500 response, the content length must be greater than 512 bytes.
Implement this padding. To do this, use the VBScript String function to return a string of the same character, which is one more than the ErrorThreshold that Internet Explorer 5.x uses to display the friendly error message. For example, add the following line immediately before the tag of 500-100.asp:
<% Response.Write String(513, "_") %>
So i bulk up response page to:
<!doctype html>
<html>
<head><title>400 Bad Request</title></head>
<body><h1>400 Bad Request</h1>
The grob must be in the frobber.
<!--
512 bytes of padding to suppress Internet Explorer's "Friendly error messages"
From: HOW TO: Turn Off the Internet Explorer 5.x and 6.x "Show Friendly HTTP Error Messages" Feature on the Server Side
http://support.microsoft.com/kb/294807
Several frequently-seen status codes have "friendly" error messages
that Internet Explorer 5.x displays and that effectively mask the
actual text message that the server sends.
However, these \"friendly\" error messages are only displayed if the
response that is sent to the client is less than or equal to a
specified threshold.
For example, to see the exact text of an HTTP 500 response,
the content length must be greater than 512 bytes.
-->
</body>
</html>
Problem solved.
What makes IE decide to show a friendly error page?
The answer is that the server’s response must meet two criteria:
- The HTTP Status code must be [400, 403, 404, 405, 406, 408, 409, 410, 500, 501, 505]
- The HTTP Response body’s byte length must be shorter than a threshold value
The byte length thresholds are stored in the registry in HKEY_LOCAL_MACHINE under the subkey \SOFTWARE\Microsoft\Internet Explorer\Main\ErrorThresholds.
- [403, 405, 410]: 256 bytes
- [400, 404, 406, 408, 409, 500, 501, 505]: 512 bytes
- otherwise: 512 bytes
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With