Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

ColdFusion 2018 onRequestEnd CFOutput issue

New Here ,
Oct 11, 2022 Oct 11, 2022

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.

 
 

 

 

213
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 13, 2022 Oct 13, 2022

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

Comment it out and see whether that helps.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 13, 2022 Oct 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.>
--->
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 13, 2022 Oct 13, 2022

BKBK, thank you for your response!

cfdump tag in test.cfm doesn't affect, I checked.

What I found is output="false" parameter in onRequestEnd function. It does affect.

If I change it to output="true" or omit it entirely, it starts working fine, I get the output content.

In case of output="true" it dumps the content generated only inside onRequestEnd function and ignores the output from test.cfm file.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 13, 2022 Oct 13, 2022

Sorry, typo... Should be:

In case of output="false" it dumps the content generated only inside onRequestEnd function and ignores the output from test.cfm file.

 
 

 

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 13, 2022 Oct 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)
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 13, 2022 Oct 13, 2022

It was output="false" parameter in OnRequestEnd

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 13, 2022 Oct 13, 2022
quote

It was output="false" parameter in OnRequestEnd

 

By sergey_croitor

 

What's in a name!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 13, 2022 Oct 13, 2022

In case of output="false" in onRequestEnd it dumps the content generated only inside onRequestEnd function and ignores the output from test.cfm file.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 13, 2022 Oct 13, 2022

And thank you for your response, Charlie!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 13, 2022 Oct 13, 2022

Deleted

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 13, 2022 Oct 13, 2022

Sorry, @Charlie Arehart and @sergey_croitor. My forum page didn't refresh. So I missed your your recent posts. Please, ignore what I said. 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 13, 2022 Oct 13, 2022

onRequestEnd.pngexpand image

@BKBK, in my case the highlighted parameter was the reason of issue. Do you have it defined in your onRequestEnd?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 13, 2022 Oct 13, 2022

FWIW, I had noticed that, but since you were doing a cfdump to a file, I presumed it may not impact. But are you saying even with that false, and a cfoutput around your blah blah, the it still didn't dump anything (from within that onrequestend)? 


/Charlie (troubleshooter, carehart. org)
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 13, 2022 Oct 13, 2022
LATEST

@Charlie Arehart, with output="false" it dumps only what is inside OnRequestEnd. It ignores the content from test.cfm. In browser I see the opposite: the content from test.cfm only, without the content from onRequestEnd.

A bit confusing  🙂 Anyway output="true" resolves my issue.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources