How do I suppress “friendly error messages” in Internet Explorer?

后端 未结 1 2052
清歌不尽
清歌不尽 2020-12-28 15:06

I want to display a custom error page:



400 Bad Request
<         


        
1条回答
  •  滥情空心
    2020-12-28 15:39

    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, "_") %>
    

    Make it bigger

    So i bulk up response page to:

    
    
    400 Bad Request
    

    400 Bad Request

    The grob must be in the frobber.

    Problem solved.

    Bonus Reading

    • MSDN Blog - IE Internals - Friendly HTTP Error Pages

    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

    0 讨论(0)
提交回复
热议问题