In my ASP.NET web app I call Session.Abandon()
in Page_Load()
. I would expect this would abandon the session straight away and the next time I reference the HttpContext.Current.Session
a new session should be created. However, putting breakpoints on the Session_End
and Session_Start
handlers in Global.asax indicates that these aren't called until the page has finished rendering.
So two questions:
1) Why?
2) How can I continue to use HttpContext.Current.Session
within a page lifecycle once Session.Abandon() has been called.
Thanks in advance!
http://msdn.microsoft.com/en-us/library/ms524310(v=vs.90).aspx
Look at the remarks section on the linked page. Looks like the session objects are only queued for deletion, and not deleted until the code finishes running.