Skip to main content
Inspiring
January 5, 2015
Answered

CF10 Cflocation Tag Not Working

  • January 5, 2015
  • 1 reply
  • 1999 views

Does anyone know what to do to fix a non-working <cflocation> tag?

Upgrading web site from WS2003 ColdFusion 8 to WS2008/64bit ColdFusion 10. Upgrading CF application has required a number of CF code  and database tweaks. Application is processing normally with the following exception

Working on site upgrade few days ago, one <cflocation> tag in web application stopped transferring to its target page.  I've placed <p> debug statements before and after the <cflocation> tag in question; and <p> debug statement at the start of the target page.  the <p> before <cflocation> displays.  But then the page ends without transferring.  No error is indicated by either CF, CF logs, or the web server.

Could this be an server application pool problem?  IIS is using DefaultAppPool application pool.

I've verified Cookie session is maintained.  Also adding CF10's SessionRotate() to application home page, made no change to <cflocation> tag's failure to process.

I'm stumped, and any help is appreciated.   Thanks

    This topic has been closed for replies.
    Correct answer GuyMcMickle

    Before/after CF (<p>,<cfinclude>,...) is added only for current debugging purpose; not part of the actual design. 

    Application currently does not use any CF OnRequestEnd functionality.  I was really wondering, as a secondary question, where an OnSessionEnd() might be implemented, considering users typically just close their browser window...

    Application is using <cflocation> tag context on almost every page.  This one page is the only one exhibiting the problem.

    I've also tried completely retyping the <cflocation> line to eliminate any non-printing characters. 


    Problem solved!

    Adobe CF10 online documentation (cflocation - ColdFusion, English documentation - Adobe Learning Resources),  states:

    ... This tag has no effect if you use it after the cfflush tag on a page. ...

    I had added numerous cfflush tags during the debugging process to "push out" data attributes before later source code errors occurred.

    Removing  all cfflush tags from the source code enabled cflocation to again start working!

    1 reply

    Legend
    January 5, 2015

    Maybe supply a code sample. I have not had any problems with CFLOCATION in any CF version -- and I use it a lot. The CFLOCATION tag simply tells the web server to respond with a 302 redirect. Now it is possibly to have some logic in your application.cfm or application.cfc that can interfere with the response -- particularly around onRequestEnd code.

    Inspiring
    January 5, 2015

    Site Application.cfm file has no onRequestEnd code. Is this handled in Application.cfm file as <cffunction> (<cffunction name="onRequestEnd"> ...  </cffunction> ) ?


    Program Code:

    315

    316    <cfset thisIDList = left(trim(thisIDList), len(thisIDList) - 1)>

    317 <p><cfoutput>before: cflocation url="dsp_complete.cfml?eventlist=#thisIDList#" (thisIDList = [#thisIDList#"]).</cfoutput></p>

    318 <cfinclude template="/includes/cfdump_all.cfm">

    310 <cflocation url="dsp_complete.cfml?eventlist=#thisIDList#" addtoken="No">

    320 <output>after: cflocation url="dsp_complete.cfml?eventlist=#thisIDList#" (thisIDList = [#thisIDList#"]).</cfoutput></p>

    321 ...

    Web Output:


         :

         :

    Module(1) "frm_confirm" returned from "SdpTicketSend.cfm".

    Module(1) "frm_confirm" finished cfloop query="getinit".

    before: cflocation url="dsp_complete.cfml?eventlist=76438" (thisIDList = [76438"]).

      

    cfdump_all.cfm:cgi - struct

    etc.     :

    Web Display:

    Note

    Note: page's footer links (below "box") are not output.

    First displayed line in target <cflocation> :

    147 <p>(3) In "dsp_complete.cfml" Start...</p>

    BKBK
    Community Expert
    Community Expert
    January 5, 2015

    Your code raises a number of issues.

    1) Is the above code an excerpt of Application.cfm? If so, then its structure is problematic, given that the code on that page runs at the beginning of every request.

    GuyMcMickle wrote:

    Site Application.cfm file has no onRequestEnd code. Is this handled in Application.cfm file as <cffunction> (<cffunction name="onRequestEnd"> ...  </cffunction> ) ?

    2) When you use Application.cfm and wish to implement business code at the end of requests, the functionality to use is the CFM page onRequestEnd.cfm. Application.cfm, like onRequestEnd.cfm, is not a CFC. Using <cffunction> in either file is meaningless.

    316    <cfset thisIDList = left(trim(thisIDList), len(thisIDList) - 1)>

    317 <p><cfoutput>before: cflocation url="dsp_complete.cfml?eventlist=#thisIDList#" (thisIDList = [#thisIDList#"]).</cfoutput></p>

    318 <cfinclude template="/includes/cfdump_all.cfm">

    310 <cflocation url="dsp_complete.cfml?eventlist=#thisIDList#" addtoken="No">

    320 <output>after: cflocation url="dsp_complete.cfml?eventlist=#thisIDList#" (thisIDList = [#thisIDList#"]).</cfoutput></p>

    3) Why place code that has the current page context before and after the cflocation tag? After all, ColdFusion will redirect to the page dsp_complete.cfml.