Subscribe to Windows IT Pro
February 05, 2002 12:00 AM

Informant: Disabling Friendly HTTP Error Messages

Windows IT Pro
InstantDoc ID #23814
Rating: (0)

When my Web applications produce an error, the client often sees only the generic HTTP 500 error without any supporting details. Of course, this lack of detail makes troubleshooting difficult. Telling users to disable Show friendly HTTP error messages in Microsoft Internet Explorer (IE) works, but doing so is difficult to manage on a client-by-client basis. What can I do on the server side to change this IE setting?

When the friendly messages feature in IE 5.x or later is enabled, IIS delivers error messages, but IE shows friendly error messages rather than those messages the Web server delivers. When you disable the feature in IE, you're in effect telling IE to show what the server is delivering. (You disable the feature in IE by selecting Tools, Internet Options; clicking the View tab; then clearing the Show friendly HTTP error messages option.)

You could deliver to the client a script, object, or executable that changes the appropriate registry setting. However, because doing so involves a high degree of trust by the client to let you make the changes, this process is almost as problematic as walking users through making the change manually. The trick is to get IE to show the error messages without having to modify the client.

IE's friendly error messages don't kick in if the number of bytes from the server's error message exceeds a certain threshold (by default, 512 bytes). Thus, if you create a custom message that exceeds 512 bytes, IE will show the custom message, complete with all the error information. (See the Microsoft article "Creating Custom ASP Error Pages" at http://support.microsoft.com/default.aspx?scid=kb;en-us;q224070 for tips about creating informative error pages.) One way to create such a custom message is simply to pad the 500;100 error page that resides in \iishelp\common\500-100.asp with enough characters that the enlarged error message exceeds IE's 512 byte threshold. To do so, add

<% Response.Write String(513, "_") %>

before the .asp file's <Body> tag.

However, in the case of some internal server errors, IIS won't deliver your custom page. The only workaround is to install an Internet Server API (ISAPI) filter to implement the padding for you. The Microsoft article "HOWTO: Disable Internet Explorer 5 'Show Friendly HTTP Error Messages' Feature on the Server Side" (http://support.microsoft.com/default.aspx?scid=kb;en-us;q294807) has a reference to such a filter.

Related Content:

ARTICLE TOOLS

Comments
  • Jason Berry
    9 years ago
    May 21, 2003

    Actually, I have been using a different solution since IIS 5 came out. I copy the 500-100.asp file from deep in the system32 directory to a new directory in wwwroot called "error". IUSR_machinename needs read access to that dir. Then in the IIS settings, go to the Custom Errors tab (this can be done globally for all sites OR per-site) and set the 500 HTTP Error to go to "/error/500-100.asp". For every site that you host that you want to offer detailed error messages, just create a virtual directory called "error" and point it to the dir you created in wwwroot.
    In terms of easiness, this is similar to your solution. But what if MS decides to "fix" that 512-byte workaround and make it a meg or something? And this solution definitely beats that crazy ISAPI "solution" that MS wants you to build.
    Thanks for your newsletter. I have been receiving it for a long time and I greatly enjoy it. About every 2 or 3 issues, you have a tip or link or story that really blows my mind. You are incredibly helpful to the web dev community. Thanks!

You must log on before posting a comment.

Are you a new visitor? Register Here

advertisement

advertisement

Windows is a trademark of the Microsoft group of companies. Windows IT Pro is used by Penton Media Inc. under license from owner.