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:[email protected]] 
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 < [email protected]> 
wrote:

>
> 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:[email protected]]
> 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 
> <[email protected]>
> 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 
> > <[email protected]>
> > 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 
> > > <[email protected]>
> > > 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:360134
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm

Reply via email to