Handling 404 errors by Coldfusion

2014-07-30 Thread Claude Schnéegans

Hi,

I'm havin someting weird hapening on mt CF 9 / Windows Web Server 2008 / IIS 7.5

My site is returning an error 404 status when some requested page does'nt 
exists.
For instance http://myDomain.com/index.cfm?p=pageid=21 return normaly page 21 
which exists,
but http://myDomain.com/index.cfm?p=pageid=999 returns an error 404 since 
there is no page 999 in the database.
This is achieved by the following code:

CFIF GetPage.recordCount EQ 0
 CFINCLUDE TEMPLATE=/commun/notFound.cfmCFABORT

and notFound.cfm contains this:
cfheader statuscode=404 statustext=Page not found
h3Page not found/h3
BRCFOUTPUTSorry, the requested page does not exists on this site A 
HREF=http://#cgi.server_name#;#cgi.server_name#/A./CFOUTPUT

Now the PROBLEM is that the generated code is displayed AFTER the text 
generated by the IIS server in case of any 404 error.
If I remove the line with statuscode=404, the page is displayed normally.

It seems that when CF is returning a 404 response, IIS fells compelled to put 
it's oar too ;-)

The problem does not happen on my development setup, with the same version of 
CF and IIS.




~|
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:359038
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm


Re: Handling 404 errors by Coldfusion

2014-07-30 Thread Jon Clausen

Claude,

This should be just a setting that needs to be adjusting in IIS:

IIS Manager [Site] Error Pages  404  -  Uncheck “Insert content from static 
file in to the error response” and/or reconfigure as fits your need.

HTH,
Jon


On Jul 30, 2014, at 2:49 PM, Claude Schnéegans schneeg...@internetique.com 
wrote:

 
 Hi,
 
 I'm havin someting weird hapening on mt CF 9 / Windows Web Server 2008 / IIS 
 7.5
 
 My site is returning an error 404 status when some requested page does'nt 
 exists.
 For instance http://myDomain.com/index.cfm?p=pageid=21 return normaly page 
 21 which exists,
 but http://myDomain.com/index.cfm?p=pageid=999 returns an error 404 since 
 there is no page 999 in the database.
 This is achieved by the following code:
 
 CFIF GetPage.recordCount EQ 0
 CFINCLUDE TEMPLATE=/commun/notFound.cfmCFABORT
 
 and notFound.cfm contains this:
 cfheader statuscode=404 statustext=Page not found
 h3Page not found/h3
 BRCFOUTPUTSorry, the requested page does not exists on this site A 
 HREF=http://#cgi.server_name#;#cgi.server_name#/A./CFOUTPUT
 
 Now the PROBLEM is that the generated code is displayed AFTER the text 
 generated by the IIS server in case of any 404 error.
 If I remove the line with statuscode=404, the page is displayed normally.
 
 It seems that when CF is returning a 404 response, IIS fells compelled to put 
 it's oar too ;-)
 
 The problem does not happen on my development setup, with the same version of 
 CF and IIS.
 
 
 
 
 

~|
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:359039
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm


Re: Handling 404 errors by Coldfusion

2014-07-30 Thread Claude Schnéegans

 IIS Manager [Site] Error Pages  404 - Uncheck “Insert content from static 
 file in to the error response” and/or reconfigure as fits your need.


Ok, I've seen that, but the problem is that I still have to give a URL to be 
executed or Respond with 302 redirect.
In fact I just need IIS to do nothing, everything I need is done in my page, I 
just need to return the 404 status to the browser



~|
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:359040
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm


Re: Handling 404 errors by Coldfusion

2014-07-30 Thread Jon Clausen

You have two options that I can see:

1) Point the static content option to an empty file (not a very good option for 
your static content 404’s)
2) Remove the 404 handler completely from the Error Pages and use your 
web.config to handle 404’s for static content and pass through existing 
responses.  The following web.config httpErrors example doesn’t fire the for 
404 handler if an existing response exists (e.g. - one generated by CF):
 remove statusCode=404 subStatusCode=-1 /
 error statusCode=404” existingResonse=“PassThrough 
path=/index.cfm/error/not_found responseMode=ExecuteURL /

(actually, now that I think about it, you could probably just add the 
PassThrough attribute to your web.config for the site and it would accomplish 
what you need to do)

A more advanced option, but my personal preference nowadays, is to put NGINX 
out in front of IIS and let it handle everything for static content.  Then just 
remove the IIS error handlers from the site and let CF handle all of those when 
the NGINX proxy is in effect.

HTH,
Jon

On Jul 30, 2014, at 3:53 PM, Claude Schnéegans schneeg...@internetique.com 
wrote:

 
 IIS Manager [Site] Error Pages  404 - Uncheck “Insert content from 
 static file in to the error response” and/or reconfigure as fits your need.
 
 
 Ok, I've seen that, but the problem is that I still have to give a URL to be 
 executed or Respond with 302 redirect.
 In fact I just need IIS to do nothing, everything I need is done in my page, 
 I just need to return the 404 status to the browser
 
 
 
 

~|
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:359041
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm