gpt4 book ai didi

internet-explorer - 如何在 Internet Explorer 中抑制 "friendly error messages"?

转载 作者:行者123 更新时间:2023-12-03 10:56:35 26 4
gpt4 key购买 nike

我想显示一个自定义错误页面:

<!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>

不幸的是,Internet Explorer 忽略了 HTTP 服务器发送的响应;隐藏我的页面并显示他们自己的:

Generic "This webpage cannot be found" IE error message

如何说服 Internet Explorer 显示发送给用户的页面?

编辑 Chrome 开始做同样的事情 in 2008 .人们要求修复它;但它被标记为 不会修复 .

您可以使用答案中的相同技巧来修复它。

最佳答案

解决方法是PADDING。

Microsoft 在知识库文章 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, "_") %>


让它更大

所以我将响应页面放大到:
<!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>

问题解决了。

奖励阅读
  • 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

    关于internet-explorer - 如何在 Internet Explorer 中抑制 "friendly error messages"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11544048/

    26 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com