I want to execute some code after a user's session has ended. Ordinarily in an ASP.NET application I could leverage the Session_End method in the Global.asax file, and it's possible to get the Session ID of the session that has just ended within that, but we're advised against modifying the Global.asax file. Instead, it's suggested to use the ApplicationEvents.SessionEnd event in a custom module instead.
I'm getting a custom event handler to trigger when a user's session ends, however I can't figure out a way to get the Session ID of the session that has just ended within the method. Does anybody know? Is it possible?
You can use Kentico wrappers like SessionHelper.GetSessionID but HttpContext.Current.Session.SessionID should work.
HttpContext.Current.Session.SessionID
Unfortunately both SessionHelper.GetSessionID() and HttpContext.Current.Session.SessionID are null when called within a method assigned to ApplicationEvents.SessionEnd.Execute, because the method is not being called in the context of a request.
ApplicationEvents.SessionEnd.Execute
Please, sign in to be able to submit a new answer.