Runs at the end of a request, after all other CFML code.


<cffunction name="onRequestEnd" returnType="void">
<cfargument type="String" name="targetPage" required=true/>

See also

onRequestStartonRequestMethod summaryManaging requests in Application.cfc in Defining the application and its event handlers in Application.cfc in the Developing ColdFusion Applications


ColdFusion passes the following parameters to the method:




Path from the web root to the requested page.


This method does not return a value; do not use the cfreturn tag.


This method has the same purpose as the onRequestEnd.cfm page. (You cannot use an onRequestEnd.cfm page if you have an Application.cfc file for your application.) This method runs before the request terminates; therefore, it can access the page context, and can generate output.This method can be useful for gathering performance metrics, or for displaying dynamic footer information.This method can access the requested page's Variables scope only if the Application.cfc file includes an onRequest method that calls the page. You can use Request scope variables to share data with the requested page, even if the Application.cfc file does not have an onRequest method.If you call this method explicitly, ColdFusion does not end the request, but does execute the method code.

Note:  When using cfabort, cflocation, or cfcontent tags, the OnAbort method is invoked instead on OnRequestEnd.


The following example displays one of two footer pages depending on whether the user has logged in:The onRequestEnd method in Application.cfc contains the following code:

<cffunction name="onRequestEnd">
<cfargument type="String" name="targetPage" required=true/>
<cfset theAuthuser=getauthuser()>
<cfif theAuthUser NEQ "">
<cfinclude template="authuserfooter.cfm">
<cfinclude template="noauthuserfooter.cfm">

A simple authuserfooter.cfm page consists of the following code:

<h3>Thank you for shopping at our store, #theAuthUser#!</h3>

A simple noauthuserfooter.cfm page consists of the following code:

<h3>Remember, only registered users get all our benefits!</h3>

To test this example, implement code for logging in a user, or try the example with and without the following line in the onRequestStart Application.cfc method:

<cfloginuser name="Robert Smith" password="secret" roles="customer">


Get help faster and easier

New user?