如何抑制“友好错误消息”?在Internet Explorer中? [英] How do I suppress "friendly error messages" in Internet Explorer?
问题描述
我想显示自定义错误页面:
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>
不幸的是,Internet Explorer忽略了HTTP服务器发送的响应;隐藏我的页面并显示自己的页面:
Unfortunately, Internet Explorer ignores the response sent by the HTTP server; hiding my page and showing their own:
如何说服Internet Explorer显示用户发送的页面?
How can I convince Internet Explorer to show the page the user was sent?
推荐答案
解决方案是PADDING。
The solution is PADDING.
Microsoft在知识库文章 KB294807 :
Microsoft notes in knowledge base article KB294807:
如何:关闭服务器端的Internet Explorer 5.x和6.x显示友好HTTP错误消息功能
...这些友好错误消息仅在以下情况下显示:发送给客户端的响应小于或等于指定的阈值。例如,要查看HTTP 500响应的确切文本,内容长度必须大于512字节。
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.
实现此填充。为此,请使用VBScript字符串函数返回相同字符的字符串,该字符串比Internet Explorer 5.x用于显示友好错误消息的ErrorThreshold多一个。例如,在标签500-100.asp之前添加以下行:
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:
<!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
是什么让IE决定显示友好的错误页面?
What makes IE decide to show a friendly error page?
答案是服务器的响应必须符合两个标准:
The answer is that the server’s response must meet two criteria:
- HTTP状态代码必须为 [400,403,404,405,406,408,409,410,500,501,505]
- HTTP响应正文的字节长度必须小于阈值
字节长度阈值存储在HKEY_LOCAL_MACHINE中的子项目\ SOFTWARE \ Microoft \Internet Explorer \ Major \ ErrorThresholds下的注册表中。
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字节
- [400,404,406,408,409,500,501,505]: 512字节
- 否则:512字节
- [403, 405, 410]: 256 bytes
- [400, 404, 406, 408, 409, 500, 501, 505]: 512 bytes
- otherwise: 512 bytes
这篇关于如何抑制“友好错误消息”?在Internet Explorer中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!