Skip to main content
Participating Frequently
October 11, 2022
Question

ColdFusion 2018 onRequestEnd CFOutput issue

  • October 11, 2022
  • 2 replies
  • 341 views

When I try to get a page content by getPageContext().getCFOutput().getString() in onRequestEnd event, I get an empty string.

When I try to get a page content at the end of cfm script by the same code, I get what I expect: not empty content.

Application.cfc:

...

 

<cffunction name="onRequestEnd" output="false" returntype="void" >
    <cfargument type="String" name="targetPage" required=true />

    <cfdump var="getPageContext().getCFOutput().getString() in onRequestEnd: [#getPageContext().getCFOutput().getString()#]" output="C:\debug\debug_test_log.html" format="html" />
</cffunction>

 

...

test.cfm:

 

 

blah blah blah
<cfdump var="getPageContext().getCFOutput().getString() in test.cfm: [#getPageContext().getCFOutput().getString()#]" output="C:\debug\debug_test_log.html" format="html" />

 

 

The debug output (dumped into file) is following:

getPageContext().getCFOutput().getString() in test.cfm: [blah blah blah ]
getPageContext().getCFOutput().getString() in onRequestEnd: []

 

Any idea why it is empty in onRequestEnd event?

I remember it was working as expected in previous CF server versions and I was able to modify or cache an output before sending to a client.

 
 

 

 

    This topic has been closed for replies.

    2 replies

    Charlie Arehart
    Community Expert
    Community Expert
    October 13, 2022

    And if bkbk's helpful idea doesn't pan out, another sanity check would be to create a new folder, with that test page (doing absolutely nothing but that blah blah, before or after), and an Application.cfc doing also nothing but that onrequestend method (and not extending any other cfc). Does the function still fail to produce any result?

     

    If that works, then clearly something else in your app.cfc (or any you extend/inherit from) or something in your test cfm is impacting your first efforts.

     

    If that's the case (or if it fails to work also in this other test), what if you wrap the blah blah in a cfoutput? Not that you should have to, but does it make any difference? Just tossing out diagnostics to try, not solutions for now. 

    /Charlie (troubleshooter, carehart. org)
    Participating Frequently
    October 13, 2022

    It was output="false" parameter in OnRequestEnd

    Once I change it to output="true" or omit it entirely, it resolves the issue.

    BKBK
    Community Expert
    Community Expert
    October 13, 2022
    quote

    It was output="false" parameter in OnRequestEnd

     

    By @sergey_croitor

     

    What's in a name!

    BKBK
    Community Expert
    Community Expert
    October 13, 2022

    The cfdump tag in test.cfm might be messing things up for you.

    Comment it out and see whether that helps.

    BKBK
    Community Expert
    Community Expert
    October 13, 2022
    quote

    The cfdump tag in test.cfm might be messing things up for you.

    Comment it out and see whether that helps.


    By @BKBK

     

    What I mean is, try something like:

    <cfoutput>blah blah blah</cfoutput>
    
    <!---
    <cfdump etc.>
    --->