Session_OnEnd() - what session?

G

Guest

Hi;

Is there some kind of session ID variable that I can get in the code behind
and that is available in Session_OnEnd() to know what session ended?
 
A

Alvin Bruney [MVP]

i certainly wouldn't count on that behavior if I were you. Session end event
fires after the session has been torn down. Relying on session at this point
may be problematic across servers.

--
________________________
Warm regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
Professional VSTO.NET - Wrox/Wiley
The O.W.C. Black Book with .NET
www.lulu.com/owc, Amazon
Blog: http://www.msmvps.com/blogs/alvin
 
G

Guest

Ok, in that case how do I identify the session? Otherwise all I know is a
session ended, but not which one.

--
thanks - dave
david_at_windward_dot_net
http://www.windwardreports.com



Alvin Bruney said:
i certainly wouldn't count on that behavior if I were you. Session end event
fires after the session has been torn down. Relying on session at this point
may be problematic across servers.

--
________________________
Warm regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
Professional VSTO.NET - Wrox/Wiley
The O.W.C. Black Book with .NET
www.lulu.com/owc, Amazon
Blog: http://www.msmvps.com/blogs/alvin
-------------------------------------------------------


David Thielen said:
Got it - the Session object appears to still be good at that point.
 
G

Guest

Session_End fires on the server and is independent of the browser which
could have been closed say, 20 minutes ago.
But if you have mapped the sessionid to some identifier such as a username,
etc. and you can gain access to a valid sessionid in the session_end event,
then I suppose it might have some limited use.
Peter
--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com




David Thielen said:
Ok, in that case how do I identify the session? Otherwise all I know is a
session ended, but not which one.

--
thanks - dave
david_at_windward_dot_net
http://www.windwardreports.com



Alvin Bruney said:
i certainly wouldn't count on that behavior if I were you. Session end event
fires after the session has been torn down. Relying on session at this point
may be problematic across servers.

--
________________________
Warm regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
Professional VSTO.NET - Wrox/Wiley
The O.W.C. Black Book with .NET
www.lulu.com/owc, Amazon
Blog: http://www.msmvps.com/blogs/alvin
-------------------------------------------------------


David Thielen said:
Got it - the Session object appears to still be good at that point.

--
thanks - dave
david_at_windward_dot_net
http://www.windwardreports.com



:

Hi;

Is there some kind of session ID variable that I can get in the code
behind
and that is available in Session_OnEnd() to know what session ended?
 
G

Guest

I get that via the Session property - correct? So what about Alvin's comment
that the Session object may be gone? (I am aware that the browser has
probably gone on to another site at this time - I have to clean up temporary
bitmap files used for the last page it was on.)

--
thanks - dave
david_at_windward_dot_net
http://www.windwardreports.com



Peter Bromberg said:
Session_End fires on the server and is independent of the browser which
could have been closed say, 20 minutes ago.
But if you have mapped the sessionid to some identifier such as a username,
etc. and you can gain access to a valid sessionid in the session_end event,
then I suppose it might have some limited use.
Peter
--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com




David Thielen said:
Ok, in that case how do I identify the session? Otherwise all I know is a
session ended, but not which one.

--
thanks - dave
david_at_windward_dot_net
http://www.windwardreports.com



Alvin Bruney said:
i certainly wouldn't count on that behavior if I were you. Session end event
fires after the session has been torn down. Relying on session at this point
may be problematic across servers.

--
________________________
Warm regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
Professional VSTO.NET - Wrox/Wiley
The O.W.C. Black Book with .NET
www.lulu.com/owc, Amazon
Blog: http://www.msmvps.com/blogs/alvin
-------------------------------------------------------


Got it - the Session object appears to still be good at that point.

--
thanks - dave
david_at_windward_dot_net
http://www.windwardreports.com



:

Hi;

Is there some kind of session ID variable that I can get in the code
behind
and that is available in Session_OnEnd() to know what session ended?
 
S

Steven Cheng[MSFT]

Hello Dave,

Glad to see you again. How are you doing recently?

As for the SessionState, the "OnEnd" event and the SessionID does has some
particular things need to take care:

1. "Session_OnEnd" event is only working for ASP.NET InProc session Mode,
and not available for StateServer or SqlServer mode.

2. The SessionID for a certain client will always change on each page
request unless our ASP.NET application explicitly add a global.asax file
and "Session_OnEnd" event or add some data into the Session State bag. You
can get more info about ASP.NET session state in the following Q&A article:

http://www.aspnetresources.com/blog/session_state_qna.aspx

And regardless of the above things, in the Session_OnEnd event(in
global.asax), you can use the "Session" property to access some certain
property (such as SessionID) of the session about to be destroyed.

BTW, as you mentioned that you're using this event to do some temp file
clean up task. IMO, I would prefer use a timer thread to constantly monitor
the temp dir and delete aged temp files through their datetime attribuets
or our custom timestamp info in the filename. How do you think of this?

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead



==================================================

Get notification to my posts through email? Please refer to

http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.



Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial

response from the community or a Microsoft Support Engineer within 1
business day is

acceptable. Please note that each follow up response may take approximately
2 business days

as the support professional working with you may need further investigation
to reach the

most efficient resolution. The offering is not appropriate for situations
that require

urgent, real-time or phone-based interactions or complex project analysis
and dump analysis

issues. Issues of this nature are best handled working with a dedicated
Microsoft Support

Engineer by contacting Microsoft Customer Support Services (CSS) at

http://msdn.microsoft.com/subscriptions/support/default.aspx.

==================================================



This posting is provided "AS IS" with no warranties, and confers no rights.
 
G

Guest

Glad to see you again. How are you doing recently?

Life is good - very busy but very good.
 
G

Guest

My concern with the timestamp approach is that if someone hits refresh, they
can keep a page active a long time. Handling it in OnEnd() seems like such a
clean way to do it.

I know it's InProc mode only - but isn't that standard for all ASP.NET apps?

--
thanks - dave
david_at_windward_dot_net
http://www.windwardreports.com
 
S

Steven Cheng[MSFT]

Thanks for your quick response Dave,

I agree that timestamp approach will have such drawbacks, however, if you
will use "Session_OnEnd" to do the cleanup task, I suggest you also put
some other cleanup code for application wide(such as in the Application's
end or Start event) since sometimes the OnEnd event of sessionState may not
get fired , for example, when there occur some unexpected exception and
application restart. Therefore, it would be better to add some additional
code to gurantee that the folder is cleaned up.

Sure, SessionState is a standard for ASP.NET applications.

Regards,

Steven Cheng
Microsoft MSDN Online Support Lead
 
G

Guest

Good point - I'll add it to the App OnStart too in case the App OnEnd was not
called and clean the directory in both cases.
 
S

Steven Cheng[MSFT]

Thanks for your followup.

Have a good day!

Regards,

Steven Cheng
Microsoft MSDN Online Support Lead


==================================================

When responding to posts, please "Reply to Group" via your newsreader so
that others may

learn and benefit from your issue.

==================================================


This posting is provided "AS IS" with no warranties, and confers no rights.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,902
Latest member
Elena68X5

Latest Threads

Top