ColdFusion 4.5 introduces a site-wide "Missing Template" (404 Error) exception-handling facility. These exception-handling templates can use the full power of CFML to produce highly customized pages.

Where do I do this?

Administrator Setting:

In the ColdFusion Administrator, click on "Settings" to view the "Server Settings" page. On this page it will allow you to specify a template that will be executed when the ColdFusion Application Server cannot find a template or a request fails. The two options you have are "Missing Template Handler" and "Site-wide Error Handler".

How does it work?

Missing Template Handler lets you specify a default template to execute any time the ColdFusion Application Server cannot find a requested template.

Site-wide Error Handler lets you specify a template to execute any time the ColdFusion Application Server encounters errors while processing a request. Below is an example of how to set these up.

Setting it up:

Missing Template Handler:

  1. In the ColdFusion Administrator, click on "Settings" to view the "Server Settings" page
  2. Specify the absolute path that ColdFusion will use to find your error handling template



    Example:

    [NT] C:\InetPub\wwwroot\MissingTemplateHandler1.cfm

    [Unix] /docroot/MissingTemplateHandler1.cfm.




Site-wide Error Handler:

  1. In the ColdFusion Administrator, click on "Settings" to view the "Server Settings" page
  2. Specify the absolute path that ColdFusion will use to find your error handling template



    Example:

    [NT] C:\InetPub\wwwroot\MissingTemplateHandler1.cfm

    [Unix] /docroot/MissingTemplateHandler1.cfm.




If you have previously enabled IIS's custom 404 error pages for .cfm files, you must disable that option so that the ColdFusion Application Server will be able to process your request and invoke the Missing Template Handler.

To do this in IIS:

  1. Go to the web sites Properties dialog
  2. Click on Home Directory
  3. Then Configurations
  4. Click on .cfm and then Edit
  5. From this dialog box disable "Check that file exists"

Coding the Template

The request's CGI, FORM, and URL variables are available to help your template diagnose the failing request. CGI.PATH_INFO and CGI.SCRIPT_NAME contain the name of the requested template. CGI.SERVER_NAME contains the name of the server from which the request was made; this can be helpful if your site hosts multiple virtual domains.

4.0.x users

To do this in ColdFusion 4.0.x releases, do the following:

  1. Open the IIS Management Console.
  2. Right-click on the default web site and select Properties.
  3. Click Home Directory and Configuration.
  4. Highlight the extension, .cfm, select Edit, and put a check in "Check if file exists." Click OK to close the Configuration dialog box. Click OK to close the Home Directory dialog box.
  5. Click on the Custom Errors tab. (You can right-click on default web site if you have closed the Properties dialog.)
  6. Scroll down and select the 404 error number (for the 404 Not Found error message.)
  7. Click Edit Properties.
  8. You may edit the error 404 file (typically at C:\WINNT\help\common\404b.htm) or change the file that IIS uses for the 404 error message.
  9. Click OK to close the dialog box for the 404 error message properties.
  10. Click OK to close the Properties dialog box.




This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License  Twitter™ and Facebook posts are not covered under the terms of Creative Commons.

Legal Notices   |   Online Privacy Policy