Customizing HTML Error Messages in IIS

Internet users certainly know the dreaded HTTP 404 error--"404 File not found." The error occurs when you try to navigate directly or indirectly by link to a URL that doesn't exist. HTTP 404 errors are inevitable. Programmers make mistakes. Some tools (e.g., Microsoft FrontPage, Microsoft Site Server 3.0 Content Analysis) can identify HTTP 404 errors, but, as you know, errors can still slip into production. Most of the time, an HTTP 404 error occurs because a page is removed from a Web site or moved to a different location. Links to the removed page remain and cause HTTP 404 errors.

The default errors that IIS serves are nothing more than Web pages in the form of .html files that live in the \winnt\help\iishelp\common\ folder, so it's easy to customize the errors that browsers receive. A custom error message can be an absolute URL on a server or a pointer to a file.

To customize your error messages, run the IIS snap-in in the Microsoft Management Console (MMC). (In Windows 2000, choose Start, Programs, Administrative Tools, Internet Services Manager.) Right-click Default Web Site and select Properties. Click the Custom Errors tab. Notice that the error messages for HTTP errors appear in numerical order. Scroll down to the 404 error, select it, and click Edit Properties. IIS serves the HTTP 404 error from the file \winnt\help\iishelp\common\404b.htm. Your Web designers can modify that file (or, more likely, create a new file) with graphics more representative of the look and feel of your Web site and with content that is more descriptive about the possible actions your users can take after receiving the error message. Alternatively, your Web developers could write an Active Server Pages (ASP) page that redirects the browser to a search page, which could help users find the page they are looking for.

Open the 404b.htm file in Microsoft Visual InterDev (or your favorite HTML editor), and change the text in line 54 (below) to something more specific to your site.

<h1 style="COLOR:000000; FONT: 13pt/15pt verdana"><!--Problem-->The page cannot be found.</h1>

Save the file, then purposely type a bad URL into your browser that connects to the server on which you edited the 404b.htm file. Notice that the change you made is immediately effective on your Web site. Now that you've seen how easy it is to customize HTTP errors on your Web site, think about ways to make error processing on your site more effective and implement your ideas.

Hide comments


  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.