Application Lifecycle Event Not Fired when Server.Transfer
-
29-09-2020 - |
Question
I have a custom rewrite module and when specific query string parameters are passed i need to be able to call a server.transfer and not a response.redirect due to adserve software and tracking
in the Init Event of the RewriteModule i register the events:
BeginRequest PreRequestHandlerExecute ReleaseRequestState
when a Response.Redirect is called the ReleaseRequestState event is actually called and the rewrite module is complete and the new control URL's are set
when a Server.Transfer is called then the ReleaseRequestState event is not called and the friendly URL's are not set
i think i understand the different between a Response.Redirect and Server.Transfer but i cannot work out why the event is actually not called - is the Session.End or Session.Abandon event being called and this the event is never fired? or is something completely different happening here
thanks
paul
Solution
I'm guessing it's the subtle differences between the two.
Response.Redirect does a client-side redirect -- meaning the client browser is sent a message telling it to request a different URL and therefore giving you a new request.
Server.Transfer doesn't create a new request (http://msdn.microsoft.com/en-us/library/y4k58xk7.aspx). It just stops working on the current page and begins work on another page -- no new request.