CF 404 handler non being invoked on IIS

226 views
Skip to first unread message

hofar...@houseoffusion.com

unread,
Feb 8, 2015, 12:35:23 PM2/8/15
to ColdFusion Technical Talk

This is working on the live hosted site, but on my local install of iis and
cf it isn't.

I have ses urls like this:

http://mysitedotcom/item-section/item-name-1034/index.cfm

The directories "item-section" and "item-name-1034" do not exist, so it
should invoke the Application.cfc onMissingTemplate function, which is set
up to serve the proper dynamic page.

However on my local setup, I am getting this iis error:

HTTP Error 404.0 - Not Found
Detailed Error Information:
Module IIS Web Core Notification MapRequestHandler Handler
cfmHandler Error
Code 0x80070002
Requested URL
http://mysitedotcom:80/site_mysubsite_com/items/item-name-1034/index.cfm
Physical
Path C:\wwwroot\site_mysite_com\item-section\item-name-1034\index.cfm Logon
Method Anonymous Logon User Anonymous
It's like CF is not even getting to see the missing template error before
IIS steps in. I tried setting Application.cfc as the error page for 404
errors but no dice. How can I make CF take priority and handle the 404
error?

Thank you.


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:360088

hofar...@houseoffusion.com

unread,
Feb 8, 2015, 4:22:05 PM2/8/15
to ColdFusion Technical Talk

You will need to change a setting in IIS for the 404 page not found and point it to a CF page designed to process those requests.

Thanks,
Brian
Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:360089

hofar...@houseoffusion.com

unread,
Feb 8, 2015, 10:07:55 PM2/8/15
to ColdFusion Technical Talk

I have added the following for a custom error page:
"Execute a url on this site"
/404.cfm

I still get the standard iis 404 error page. I have restarted the server.
Is there something else I need to do? Thanks.


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:360090

hofar...@houseoffusion.com

unread,
Feb 9, 2015, 3:55:25 AM2/9/15
to ColdFusion Technical Talk

It would seem that your url rewriting is not working if you are getting 404
on the original url., otherwise you get error on the rewritten url at least.
Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:360091

hofar...@houseoffusion.com

unread,
Feb 9, 2015, 8:42:53 AM2/9/15
to ColdFusion Technical Talk

Formerly, in IIS you could check a box that told IIS to not check first if
a page exists on the .cfm extension, which would defeat IIS handling .cfm
404 errors. From there your CF 404 error template would take over. This
behavior changed as IIS was upgraded. So Item 1: If you are using an
earlier version of IIS the solution is different. Your version?

Look at this:

http://stackoverflow.com/questions/18879758/coldfusion-10-update-11-404-handler-not-firing

this was part of my discovery that CF 10/Win2k8 error handling was
different from CF9/Win2k3. From this, thre observation that IIS was
returning as the failed url

http://[mydomain]:80/jakarta/isapi_redirect.dll

became a CF bug that I am pretty sure got fixed. My eventual solution
was posted up here

http://stackoverflow.com/questions/18237478/iis7-displays-both-its-own-404-message-cf9-message-should-display-just-its-ow/18927484#18927484

and involved using a local site 404 template handler rather than one
specified in the CF admin. If you follow the two discussions there were a
lot of suggestions that wound up doing half the job, or an unacceptable
version (IIS + CF errors shown, 200 codes returned) but the above fixed the
lot.

--
--m@Robertson--
Janitor, The Robertson Team
mysecretbase.com


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:360092

hofar...@houseoffusion.com

unread,
Feb 9, 2015, 4:48:10 PM2/9/15
to ColdFusion Technical Talk

Matt,
Thank you for the link. I am working through the first step below:

*Step 1:*
Configure a Missing Template Handler in CF Administrator. Mine is global to
the server and kept in the ColdFusion webroot - which is separate from the
IIS web root and whose default location is c:\ColdFusion9\wwwroot. This
global template is 404handler.cfm and contains the following simple code,
which you can expand upon:

<h1>404</h1><p>Page Not Found</p><cfheader
statuscode="404"
statustext="Not Found">

At this point, visit your web site and execute a bad ColdFusion url:
*http://[domain]/bogus.cfm*. You will see both the IIS remote error
screen/banner followed by your ColdFusion error screen. Check the header
and it is a 404. This next step will solve the dual display problem.


When I visit the bogus page, I still just get the standard detailed iis 404
page, without the cf page that I created. I have tried it both with and
without the "Enable HTTP status codes". I can't figure out what I am doing
wrong. This is on a windows 8 machine. Any ideas? Thank you for the help.


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:360096

hofar...@houseoffusion.com

unread,
Feb 9, 2015, 5:09:39 PM2/9/15
to ColdFusion Technical Talk

I deal with many sites that have non existent pages which use URL REWRITE
to redirect them.
The usual reason is that the url rewrite rules are not working, or even
that the url rewrite module is not installed.
Have you tried a very simple rule to test of that is working ok ?
Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:360097

hofar...@houseoffusion.com

unread,
Feb 9, 2015, 8:31:14 PM2/9/15
to ColdFusion Technical Talk

Url rewrite in IIS may not even be involved here, and need not be. Prior
to win2k8 the standard way to handle Cf 404 and 'fakeURL' 404's was to tell
IIS not to 'check to see if file exists' in the .cfm mapping. From there
CF server's 404 handler did whatever you wanted it to. To retain the same
capability with dynamic urls i had to jump thru the hoops described above
in win2k8. Current method of individual site 404 handlers is a pain but
more flexible.
Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:360098

hofar...@houseoffusion.com

unread,
Feb 9, 2015, 8:33:38 PM2/9/15
to ColdFusion Technical Talk

ok I thought I saw him say earlier on he was using url rewrite, maybe I was
mistaken

On Tue, Feb 10, 2015 at 1:30 AM, Matt Robertson <websit...@gmail.com>
wrote:
Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:360099

hofar...@houseoffusion.com

unread,
Feb 9, 2015, 8:39:06 PM2/9/15
to ColdFusion Technical Talk

>
> Mark,

those two threads aren't exactly a linear set of to do steps. I'll try to
put that together tomorrow when I am in front of a desktop.



> --
> --m@Robertson--
> Janitor, The Robertson Team
> mysecretbase.com
>


--
--m@Robertson--
Janitor, The Robertson Team
mysecretbase.com


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:360100

hofar...@houseoffusion.com

unread,
Feb 11, 2015, 7:03:31 AM2/11/15
to ColdFusion Technical Talk

Thank you, I would appreciate that.

On Mon, Feb 9, 2015 at 6:38 PM, Matt Robertson <websit...@gmail.com>
wrote:

>
> >
> > Mark,
>
> those two threads aren't exactly a linear set of to do steps. I'll try to
> put that together tomorrow when I am in front of a desktop.
>
>


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:360102

hofar...@houseoffusion.com

unread,
Feb 11, 2015, 7:09:21 AM2/11/15
to ColdFusion Technical Talk

>Have you tried a very simple rule to test of that is working ok ?

The url rewrite is just pointing to serve the site from a subdirectory. It
is working ok because the home page is being served correctly. Thanks,

On Mon, Feb 9, 2015 at 3:09 PM, Russ Michaels <ru...@michaels.me.uk> wrote:

>
> I deal with many sites that have non existent pages which use URL REWRITE
> to redirect them.
> The usual reason is that the url rewrite rules are not working, or even
> that the url rewrite module is not installed.
> Have you tried a very simple rule to test of that is working ok ?
>
>
>
>


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:360103

hofar...@houseoffusion.com

unread,
Feb 12, 2015, 8:32:12 AM2/12/15
to ColdFusion Technical Talk

After playing with it a bit more I added this:
<httpErrors existingResponse="PassThrough"/>

Now I just get a blank page.

Am I successfully passing it through to cf? Hard to tell. I was hoping to
have made a bit of progress.

On Mon, Feb 9, 2015 at 6:38 PM, Matt Robertson <websit...@gmail.com>
wrote:

>
> >
Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:360114

hofar...@houseoffusion.com

unread,
Feb 13, 2015, 6:24:19 PM2/13/15
to ColdFusion Technical Talk

sorry for my lack of attention on this. If you are in fact using IIS
Rewrite then that clouds the picture a little. However if I can pull
myself together and write something up you should be able to do all of your
404 handling in your ... 404 handler. I don't use IIS rewrites for much
and instead rely on CF wherever possible. Will try and find some time this
long weekend (holiday here in the USA).
Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:360119

hofar...@houseoffusion.com

unread,
Feb 18, 2015, 12:06:46 AM2/18/15
to ColdFusion Technical Talk

I'm trying to make do with using a custom 404 handler in IIS but the
requested template variable in CF resolves to to 404 handler rather than
the url of the requested page. This is getting complicated as this is only
a work around for local development and I don't want to change to much and
break the live site.

Does anyone have any other pointers on how I can get this working like the
live site?

I can't believe that it is this problematic to get CF to be passed the 404
error and invoke the onmissingtemplate. What changed so drastically in iis
8 and cf11 that something so basic is so broken?

On Fri, Feb 13, 2015 at 4:24 PM, Matt Robertson <websit...@gmail.com>
Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:360130

hofar...@houseoffusion.com

unread,
Feb 18, 2015, 8:11:40 AM2/18/15
to ColdFusion Technical Talk

I'm not sure if this has already been mentioned but Adobe just posted a blog article about custom error handling with ColdFusion and IIS. Once you get over how it was written they do give you three different scenarios for configuring your error handling. It's nice to finally get confirmation from them on how it works.

http://blogs.coldfusion.com/post.cfm/onmissingtemplate

-----Original Message-----
From: Mark Spence [mailto:markpe...@gmail.com]
Sent: Wednesday, February 18, 2015 12:07 AM
To: cf-talk
Subject: Re: CF 404 handler non being invoked on IIS


I'm trying to make do with using a custom 404 handler in IIS but the requested template variable in CF resolves to to 404 handler rather than the url of the requested page. This is getting complicated as this is only a work around for local development and I don't want to change to much and break the live site.

Does anyone have any other pointers on how I can get this working like the live site?

I can't believe that it is this problematic to get CF to be passed the 404 error and invoke the onmissingtemplate. What changed so drastically in iis
8 and cf11 that something so basic is so broken?

On Fri, Feb 13, 2015 at 4:24 PM, Matt Robertson <websit...@gmail.com>
Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:360131

hofar...@houseoffusion.com

unread,
Feb 18, 2015, 3:17:34 PM2/18/15
to ColdFusion Technical Talk

Miguel,

Thanks for the article. It was a little confusing as it seemed to
reference "onMissingTemplate" as the setting in administrator rather than
the function in Application.cfc. And that is what I am trying to invoke,
the function in Apllication.cfc. Is that no longer possible? I seem to be
in a bit of a conundrum here. My local dev machine is windows 8 which
requires the higher versions of IIS and CF, while the production site is
CF9.

To give a better idea of where I am at, I have this in the web.config:
<httpErrors errorMode="Detailed" existingResponse="PassThrough">

And now I get a blank page from the 404 pages. I assume that either CF is
not returning anything or IIS is discarding the response.

Here is what I have in the onMissingTemplate function:

<cffunction name="onMissingTemplate" returnType="boolean">
<cfargument type="string" name="targetPage" required=true/>
<cfheader statusCode="200" statusText="OK">hello
<!---
<cfobject component="cfcs.404" name="handle_404" />

<cfset variables.temp = handle_404.handle_404(requested_template =
arguments.targetPage)>
--->
<cfreturn True />
</cffunction>

This is a try based upon the article but I think it is in vain and would
only apply to a specified missing template handler page.

I'm not sure what to try at this point. I could be off by one little
setting, or what I want to do is just not possible, which is just to have
the missing pages handled by invoking Application.cfc's onMissingTemplate
function like the live server does. I don't want to do back to Apache
after putting to much time into this, especially since the live server is
IIS.

Thanks for any help you can offer.
Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:360133

hofar...@houseoffusion.com

unread,
Feb 18, 2015, 3:39:07 PM2/18/15
to ColdFusion Technical Talk

Yes you can use the onMissingTemplate handler in Application.cfc if you wish, it just overrides the ColdFusion admin setting.
I think you missed the gist of that article that I referenced. Basically there are three scenarios; use IIS custom error page, use ColdFusion missing template handler or use both. The caveat's mentioned are that the onMissingTemplate handler cannot be used to return contents to the user, it should only be used to log/email/whatever the event. If you want to return a custom message to the user then use IIS custom error page to do that (calling a ColdFusion page). Or you can use both. The key for that scenario is to have each pointing to a different ColdFusion file (when using the admin setting). In your case, using the method in Application.cfc, just do your logging or whatever and then return the 404 status code to IIS so it will display it's custom error page. It looks like you are setting a "200 OK" in your method. You don't want to do that as IIS will not know about the error.

-----Original Message-----
From: Mark Spence [mailto:markpe...@gmail.com]
Sent: Wednesday, February 18, 2015 3:17 PM
To: cf-talk
Subject: Re: CF 404 handler non being invoked on IIS


Miguel,

Thanks for the article. It was a little confusing as it seemed to reference "onMissingTemplate" as the setting in administrator rather than the function in Application.cfc. And that is what I am trying to invoke, the function in Apllication.cfc. Is that no longer possible? I seem to be in a bit of a conundrum here. My local dev machine is windows 8 which requires the higher versions of IIS and CF, while the production site is CF9.

To give a better idea of where I am at, I have this in the web.config:
<httpErrors errorMode="Detailed" existingResponse="PassThrough">

And now I get a blank page from the 404 pages. I assume that either CF is not returning anything or IIS is discarding the response.

Here is what I have in the onMissingTemplate function:

<cffunction name="onMissingTemplate" returnType="boolean">
<cfargument type="string" name="targetPage" required=true/>
<cfheader statusCode="200" statusText="OK">hello
<!---
<cfobject component="cfcs.404" name="handle_404" />

<cfset variables.temp = handle_404.handle_404(requested_template = arguments.targetPage)>
--->
<cfreturn True />
</cffunction>

This is a try based upon the article but I think it is in vain and would only apply to a specified missing template handler page.

I'm not sure what to try at this point. I could be off by one little setting, or what I want to do is just not possible, which is just to have the missing pages handled by invoking Application.cfc's onMissingTemplate function like the live server does. I don't want to do back to Apache after putting to much time into this, especially since the live server is IIS.

Thanks for any help you can offer.

On Wed, Feb 18, 2015 at 6:10 AM, Fernandez, Miguel < Miguel.F...@kyfb.com> wrote:

>
Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:360134

hofar...@houseoffusion.com

unread,
Feb 18, 2015, 4:12:29 PM2/18/15
to ColdFusion Technical Talk

Sorry for the misunderstanding, but he 404 is for pages the are ses product
pages. So I need the content to be returned to the user. An example would
be thus:

http://www.mysite.com/productpages/category/product-103/index.cfm

I am pulling "productpages" to see that it is a product page and "103" to
get the product id. All I need is for CF to catch the 404 error, invoke
the onmissingtemplate in Application.cfc, and everything works. This is
what is happening on the live site with IIS and CF9.

The problem with using IIS's custom error page for 404 is that the
requested template variable is the 404 page itself, which doesn't work with
my code. I am hoping that there is something I can configure in CF and IIS
rather than rewriting everything just for the development server.

The code I posted in my last response was just to show that it seems that
Application.cfc is not being invoked, the response is being discarded, or
something else is going on.


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:360135

hofar...@houseoffusion.com

unread,
Feb 18, 2015, 7:31:53 PM2/18/15
to ColdFusion Technical Talk

GOT IT!

It was a setting under IIS:

Under "Handler Mappings", double-click on the handler for ".cfm". Then
click the "Request Restrictions..." button. It should open to the
"mappings" tab. The "Invoke handler only if request is mapped to:" checkbox
should NOT be checked.
Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:360136

hofar...@houseoffusion.com

unread,
Feb 19, 2015, 5:31:43 AM2/19/15
to ColdFusion Technical Talk

Do you have iis6 compatibility mode installed? Rgis can cause odd behaviour.
If so remove all connectors, then remove iis6 mode then recreate connectors


On Wed, Feb 18, 2015 at 5:06 AM, Mark Spence <markpe...@gmail.com> wrote:


I'm trying to make do with using a custom 404 handler in IIS but the
requested template variable in CF resolves to to 404 handler rather than
the url of the requested page. This is getting complicated as this is only
a work around for local development and I don't want to change to much and
break the live site.

Does anyone have any other pointers on how I can get this working like the
live site?

I can't believe that it is this problematic to get CF to be passed the 404
error and invoke the onmissingtemplate. What changed so drastically in iis
8 and cf11 that something so basic is so broken?

On Fri, Feb 13, 2015 at 4:24 PM, Matt Robertson <websit...@gmail.com
<javascript:;>>
wrote:

>
> sorry for my lack of attention on this. If you are in fact using IIS
> Rewrite then that clouds the picture a little. However if I can pull
> myself together and write something up you should be able to do all of
your
> 404 handling in your ... 404 handler. I don't use IIS rewrites for much
> and instead rely on CF wherever possible. Will try and find some time
this
> long weekend (holiday here in the USA).
>
> On Thu, Feb 12, 2015 at 5:31 AM, Mark Spence <markpe...@gmail.com
<javascript:;>>
> wrote:
>
> >
> > After playing with it a bit more I added this:
> > <httpErrors existingResponse="PassThrough"/>
> >
> > Now I just get a blank page.
> >
> > Am I successfully passing it through to cf? Hard to tell. I was hoping
> to
> > have made a bit of progress.
> >
> > On Mon, Feb 9, 2015 at 6:38 PM, Matt Robertson <websit...@gmail.com
<javascript:;>>
> > wrote:
> >
> > >
> > > >
> > > > Mark,
> > >
> > > those two threads aren't exactly a linear set of to do steps. I'll
try
> > to
> > > put that together tomorrow when I am in front of a desktop.
> > >
> > >
> > >
> > > > --
> > > > --m@Robertson--
> > > > Janitor, The Robertson Team
> > > > mysecretbase.com
> > > >
> > >
> > >
> > > --
> > > --m@Robertson--
> > > Janitor, The Robertson Team
> > > mysecretbase.com
> > >
> > >
> > >
> >
> >
>
>



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:360137
Reply all
Reply to author
Forward
0 new messages