Contact Us
 
 
 
 
  Browse by category :
 

Bob and the Knowledge Factory / Windows / Internet Information Services (IIS) / Creating custom CFM error pages

Creating custom CFM error pages

Add comment
Views: 910
Votes: 0
Comments: 0
Posted: 19 Apr, 2008
by: Paul L.
Updated: 20 Feb, 2009
by: Harish R.

When IIS can't serve a file requested, it has two choices:-

1) It can send a "missing file status code" back to the browser in the response header which is a 404 or "Not Found" error message.

2) It can actually serve whatever file is specified in the "custom errors" for that site. IIS is pre-configured with custom error templates that are simple HTML files which may be served instead of the actual status code.

However, you don't actually have to use a file at all - you can use a URL from your site. This is where ColdFusion plays a vital part.

What you need to do is to :-

a) Open your website in IIS. Goto Properties and choose "Custom Errors".
b) Click on the 404 custom error and choose "Edit".
c) Change the message type to "URL".
d) Enter the relative path to a .cfm script on your site.
 
You need to enter the relative path of the file here that resides in your site rather than providing the complete URL.  If you put in a full URL, IIS would actually have to retrieve content using HTTP using a completely separate request. Instead, IIS wants to simply replace the erroneous part of the header information with the "known good" file mapping and continue on with the request as if it had been for the missing file template in the first place. That means that a request that hits the missing file template is about as fast as if the file specified had existed in the first place.

So, if IIS merely replaces the non-existent "/mypath/mypage.cfm" with a mapping from the custom error handler setting from the 404 error and continues on, then you may use a .cfm page for your 404 handler.

 If you have specified "404Handler.cfm" and set the message type to URL in the custom error page. The request continues as before and the it is handed off to the ColdFusion server for processing with the original path sent forward as a the cgi.query_string variable. ColdFusion server parses through the script looking for commands and CF tags and sends the results back to IIS which serves it up to the user.

There are times when custom CFM error pages may not work. To troubleshoot this you need to know how IIS and Coldfusion work together to handle a request. When IIS gets a request it uses the host header or IP address to find the correct site. When IIS sees a .cfm file it simply hands it to ColdFusion without even checking to see if its a legitimate template. Coldfusion must then figure out what to do with it. When the template doesn't exist, ColdFusion calls the "missing file handler" that is set up with ColdFusion administrator. So we get error message from the ColdFusion engine. What is needed is a way to make IIS check to see if the file exists before it hands off to ColdFusion.

This may be resolved as follows:-

Goto IIS and open your site properties. Click on the "home directory" tab and then click on the configuration button. If you have a typical setup you should see the Jrun wildcard entry in the bottom list box. Select this entry and click on "Edit". There is a checkbox that says "verify that file exists". It means for IIS to make sure and verify that the file referenced in the request actually exists before throwing it to the Jrun.
Others in this Category
document Web service extension
document Obtain email account password from Mail enable
document MMC error in IIS
document Enabling .aspx extension
document Configuring a website in Windows IIS
document Backup/Restore IIS Metabase.
document Enabling Server Side Includes ( SSI )
document Automating IIS back up
document How to determine w3wp.exe belongs to which Application pool in IIS6
document Unable to send or receive mail - Using IIS SMTP
document Running Apache and IIS 6 together on the same server
document The resource cannot be found error in IIS



RSS
Content is available under Creative Commons Attribution-Share Alike 3.0 License.