I've writtten some code which stores the URL to which we want to redirect the user in a variable, rather than cflocating them immediately. This allows us to do subsequent code processing before the redirection actually occurs.
Sometimes I want redirection occur before any page processing is done (such as when the user must be taken to the "Change your password" page) -- in which case the cflocation is done as the last line in onRequestStart() -- and sometimes I want it to occur after the page has been processed (such as at the end of the page that processes their login) -- in which case the cflocation is done as the last line in onRequestEnd().
All was nice and sunny until we upgraded to 9.0.1.
In earlier versions, onRequestEnd() wasn't being executed and cflocation was therefore only being called once.
After upgrading, instead of the user being redirected to (say) "/options/", they are being redirected to (the invalid URL) "/options/,/options/". The URL appears to be being concatentated (once when called from onRequestStart() and once from onRequestEnd() ) and then sent to the client.
This change in behaviour is because of one of the issues fixed in Adobe® ColdFusion® 9.0 Update 1 (issue 80798, "The function onRequestEnd fails to execute when the tags cfabort or cflocation is used.")
Can I suggest an alteration be made in future versions or fixes? Either:
a) developers are enabled to programmatically determine the URL to which a cflocation has been issued (which would allow me to skip the call to cflocation in onRequestEnd() ), or
b) if a cflocation has been issued, ColdFusion doesn't honour any subsequent calls to cflocation.
I suggest that you do a variation of a. In other words, use a global boolean variable in your application.cfc. Assign the appropriate value in your onRequestStart if you use cflocate. In your onRequestEnd, use that value to decide what you are going to do.
Thanks for the reply, Dan.
Yeah, that's what I've ended up doing... just using a Appliction.cfc-level boolean to determine whether we've already done a cflocation yet or not.
I inherently don't like having to do that, and am almost certain someone once told me how (using Java) you can read the cflocation "queue", but can't lay my hand on the correspondence.
Anyway, it's working again, so thanks!