I've set the "do not reuse session Ids" in my web.config, so each user's session has a unique session ID each time they start the application. What I'm after in my session_end code is to write a message into
my app operations log indicating the end of the session, the session_ID, and the reason the session ended (such as session timeout, user closing the session, and anything else relevent to the session being ended).
Here's what I have so far:
void Session_End(object sender, EventArgs e)
{
// Code that runs when a session ends.
// Note: The Session_End event is raised only when the sessionstate mode
// is set to InProc in the Web.config file. If session mode is set to StateServer
// or SQLServer, the event is not raised.
logging log = new logging();
string SessionIdentifier = "No session Id available";
if (Session != null) SessionIdentifier = Session.SessionID.ToString();
log.message(logging.level.critical, "Session Ending SessionId:" + SessionIdentifier);
}
I'm still debugging this, so I may have a bit more information as to what's causing the "non-instanciated object" exception.
elbilo
Participant
768 Points
178 Posts
Determining the sessionID of a session timing out
Nov 30, 2012 09:30 PM|LINK
Is there a way from say the Global.asax to determine the session ID of a session that is ending?
Is there a "Session Ending" event or only the Session_End event?
Is there a place I could store the sessionId in memory that would still be valid from within the Session_End event handler?
BrockAllen
All-Star
27534 Points
4907 Posts
MVP
Re: Determining the sessionID of a session timing out
Nov 30, 2012 09:52 PM|LINK
What are you really trying to do? SessionID is tricky since it's re-used across logical sessions.
DevelopMentor | http://www.develop.com
thinktecture | http://www.thinktecture.com/
elbilo
Participant
768 Points
178 Posts
Re: Determining the sessionID of a session timing out
Dec 03, 2012 05:52 PM|LINK
I've set the "do not reuse session Ids" in my web.config, so each user's session has a unique session ID each time they start the application. What I'm after in my session_end code is to write a message into my app operations log indicating the end of the session, the session_ID, and the reason the session ended (such as session timeout, user closing the session, and anything else relevent to the session being ended).
Here's what I have so far:
void Session_End(object sender, EventArgs e) { // Code that runs when a session ends. // Note: The Session_End event is raised only when the sessionstate mode // is set to InProc in the Web.config file. If session mode is set to StateServer // or SQLServer, the event is not raised. logging log = new logging(); string SessionIdentifier = "No session Id available"; if (Session != null) SessionIdentifier = Session.SessionID.ToString(); log.message(logging.level.critical, "Session Ending SessionId:" + SessionIdentifier); }I'm still debugging this, so I may have a bit more information as to what's causing the "non-instanciated object" exception.