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 found a pretty good work-around for this after literally days of trial and error, testing all the other suggestions out there include the one above (none of which ever worked 100% for one reason or another).

 

For this situation, leave all the default IIS 7.5 error settings.  You won't be touching IIS for any of this.  However, you will need to create a web.config file on your root that looks like this (which will overwrite any IIS settings you have anyway):

 

<?xml version="1.0" encoding="UTF-8"?>

<configuration>

  <system.webServer>

    <httpErrors existingResponse="PassThrough" />

  </system.webServer>

</configuration>

 

The PassThrough setting turns off IIS error handling altogether basically, and allows CF to handle errors via your mappings in CF admin for the missing template handler and the site-wide error hander.  You should set those to whatever you want in CF admin to handle your 404's and 500's, and throw the appropriate CFHEADER status for each.

 

The last remaining problem was how to handle 404's for directories and non-cfm files that don't exist since those requests would be bypassing CF and IIS is set to ignore.  Those kinds of pages would come back BLANK with 0 byte, and although the 404 header status code was correct, it's not very user-friendly.  The solution  was to use my existing ISAPI Rewrite module to force a custom 404 when a non-cfm file or directory is found, like this:

 

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule . /error404.cfm [NC,L,NS]

 

Using this setup, I am able to use my custom CF 404/500 error handers like how it worked in IIS 6, AND, still get proper header codes and proper handling for non-CF files and directories.  I would be intersted to hear back whether this does or does not work for people.  Hopefully it saves someone some time.

 

P.S.  My post is a summary of all the advice given on this page, so most credit goes here (I pretty much ruled out everything else): http://stackoverflow.com/questions/4968018/coldfusion-error-and-iis7-5 -error-pages


Viewing all articles
Browse latest Browse all 21760

Trending Articles



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