ASP.Net: Server.Transfer() results in HttpModule ReleaseRequestState handler not being called?
We have a response filter that intends to filter the text looking for urls to ensure querystrings are encrypted. We have an http module implementing a ReleaseRequestState handler where we attach the filter to the Response object.
We discovered an oddity whereby one .aspx page doing a Server.Transfer() to another in the same app results in the ReleaseRequestState handler never being run, so consequently our output filter never gets attached.
The setup predates me, so I don't know why the filter was hooked up in ReleaseRequestState, but I'm puzzled why doing a Server.Transfer would result in that event never firing. Anyone have any ideas?
Per MSDN, Server.Transfer internally calls Response.End, which skips all remaining pipeline events and jumps straight to EndRequest.
EndRequest is indeed the only pipeline event that is ever guaranteed to be run during an ASP.NET request (assuming its containing module is registered properly in config) precisely because every other event can be bypassed via a call to Response.End or HttpApplication.CompleteRequest.
You may wish to consider hooking your filter earlier in the pipeline to minimize the chance of some other component skipping its invocation.