Using server.Transfer() from Application_BeginRequest harm session

Well I know it little bit twisted but If it happened to one of us, probably it could be happened to others. If for some reason you need to catch request in pipeline before page is called and you choose to use Application BeginRequest event. Using server transfer to transfer request to other page from that event will end up without session object and session cookies. Doing so you bypass regular request pipeline and simply don’t call session module who responsible for sessions handling.

You can overcome this behavior by catching application PreRequestHandlerExecute which occurred before calling handlers such as page or web service. At this pipeline step session has been initializing and you won't get session buggy behavior.

1 Comment

Comments have been disabled for this content.