Quantcast
Channel: Adobe Community: Message List - ColdFusion
Viewing all articles
Browse latest Browse all 21760

Re: CF10 and IIS 7.5 - cfheader in 404 custom error handler not working correctly

$
0
0

I just went through this exercise, having problems using CFERROR with 64-bit CF10 in combination with  IIS 7.5 on Windows 2008 server.  After several days of trial and error I finally found a solution that works perfectly by letting me keep my custom 404 and 500 pages while transmitting proper http status codes.  Btw, up to this point none of the other suggestions I have found online, including those above, worked 100%.

 

You have to use a combination of IIS 7.5 and ColdFusion admin settings like this:

 

1) On IIS 7.5 you leave the default "Custom error pages" setting.  Do not use "Detailed errors".

 

Capture1.JPG

 

 

2) Right-click to edit the 404 and 500 custom error codes. Change the first option to "insert content from a static file" to 404.htm and 500.htm, respecively.  You have to UN-check the "Try to return error in client language" box to enable the field and then you simply type in the file name.  Do not use a forward slash before the filename.  The filename itself doesn't matter, but I'm using 404/500 so I always know what these files mean on my root.

 

Capture2.JPG

 

3) Now create actual 404/500.htm files and put them on the root of your site.  The custom 404.htm you create will be the message you want a user to see when they try to access a directory or HTML file that doesn't exist (this is not for missing .cfm's, that is in the next step).  The custom 500.htm you create needs to be BLANK/EMPTY, otherwise, whatever you put in the 500.htm will show up a the top of your custom ColdFusion error handler page.

 

4) Now specify a custom Missing Template Handler and Site-Wide Error Handler in CF admin like this:

 

Capture3.JPG

 

5) Your custom 404.cfm file is the file you create to handle missing .cfm files and contains <cfheader statuscode="404">.  It can be whatever you want and contain the CF code you want to execute (theoretically, the rendered code should match whatever static code you put inside the 404.htm file so your users have a consistence 404 experience).  Remember that this .cfm file is for ALL sites runing under your CF Admim, so you will need to include conditional logic that points to handler files under each site root if you have more than one.

 

6) Your custom 500.cfm file will contain all of your error diagnostics code including <cfheader statuscode="500"> that you would normally include in your CFERROR tag since CFERROR, currently, does not work right with IIS 7.5..it always returns a 404 error...see bugbase link above.

 

The important thing to note here is that your http header status codes will all be correct.  Give it a try and provide feedback here if this does or does not work for you.


Viewing all articles
Browse latest Browse all 21760

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>