Hi All,

Not sure how to categorize this, as it's likely intended behavior. But in
any case, it was a "gotcha" for me and I wanted to share :-)

We were trying to do a redirect from within the "On Request" event handler.
Originally, we had done this using the standard "redirect" command. This
has worked fine in the past (4D12.4, A4D 5.0r36). However, after our
upgrade to 4Dv13.1 and A4D 6.0.2, we noticed that even though the redirect
worked, the originally requested paged was still *executed* (any traces or
log messages contained were still being shown/written). I had thought this
wouldn't happen, as the "redirect" command stops script  execution.

Strange. So, back to the docs. On page 126 I was reading up on the event
handlers and saw that:

You may redirect to another URL by setting a response of 303 (See Other)
> or 301 (Moved Permanently) and setting a “Location” response header with
> the full target URL.


Sure, enough, using the "set response status" and "set response header"
commands correctly issued the redirect, and *did not* execute the
originally requested page. Execution was stopped.

I was curious as to why this combination works, but the "redirect" command
didn't. It looks like it boils down to the response status that is being
set. By explicitly setting the status to "303", everything worked fine.
However, the "redirect" command seems to be setting the response status to
"302" when used in the context of the "on request" handler. It doesn't
matter if you pass the second parameter or not. When used in the context of
the embedded script being executed, it will issue the expected "301" or
"303" statuses.

My takeaway is to follow the docs and explicitly set the response status.
But if anyone knows why the "redirect" issues a 302 when called from within
the event handler, I'd be curious!

Thanks,
- Clayton

-- 

*Clayton Donahue*

iVantage Health Analytics™ | Formerly  HMC, Inc.
300 Chestnut St. Ste. 101 | Needham, MA 02492
o: 781.449.5287 | f: 781.449.8058
email: [email protected]  web: www.ivantagehealth.com

___________________________________________________

Intelligence for the NEW Healthcare
_______________________________________________
Active4D-dev mailing list
[email protected]
http://list.aparajitaworld.com/listinfo/active4d-dev
Archives: http://active4d-nabble.aparajitaworld.com/

Reply via email to