473,563 Members | 2,633 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Session_OnEnd() - what session?

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?

--
thanks - dave
david_at_windwa rd_dot_net
http://www.windwardreports.com

Jul 16 '06 #1
11 2082
Got it - the Session object appears to still be good at that point.

--
thanks - dave
david_at_windwa rd_dot_net
http://www.windwardreports.com

"David Thielen" wrote:
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?

--
thanks - dave
david_at_windwa rd_dot_net
http://www.windwardreports.com
Jul 16 '06 #2
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" <th*****@nospam .nospamwrote in message
news:AF******** *************** ***********@mic rosoft.com...
Got it - the Session object appears to still be good at that point.

--
thanks - dave
david_at_windwa rd_dot_net
http://www.windwardreports.com

"David Thielen" wrote:
>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?

--
thanks - dave
david_at_windw ard_dot_net
http://www.windwardreports.com

Jul 16 '06 #3
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_windwa rd_dot_net
http://www.windwardreports.com

"Alvin Bruney [MVP]" wrote:
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" <th*****@nospam .nospamwrote in message
news:AF******** *************** ***********@mic rosoft.com...
Got it - the Session object appears to still be good at that point.

--
thanks - dave
david_at_windwa rd_dot_net
http://www.windwardreports.com

"David Thielen" wrote:
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?

--
thanks - dave
david_at_windwa rd_dot_net
http://www.windwardreports.com


Jul 16 '06 #4
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" wrote:
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_windwa rd_dot_net
http://www.windwardreports.com

"Alvin Bruney [MVP]" wrote:
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" <th*****@nospam .nospamwrote in message
news:AF******** *************** ***********@mic rosoft.com...
Got it - the Session object appears to still be good at that point.
>
--
thanks - dave
david_at_windwa rd_dot_net
http://www.windwardreports.com
>
>
>
"David Thielen" wrote:
>
>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?
>>
>--
>thanks - dave
>david_at_windw ard_dot_net
>http://www.windwardreports.com
>>
Jul 16 '06 #5
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_windwa rd_dot_net
http://www.windwardreports.com

"Peter Bromberg [C# MVP]" wrote:
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" wrote:
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_windwa rd_dot_net
http://www.windwardreports.com

"Alvin Bruney [MVP]" wrote:
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" <th*****@nospam .nospamwrote in message
news:AF******** *************** ***********@mic rosoft.com...
Got it - the Session object appears to still be good at that point.

--
thanks - dave
david_at_windwa rd_dot_net
http://www.windwardreports.com



"David Thielen" wrote:

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?
>
--
thanks - dave
david_at_windwa rd_dot_net
http://www.windwardreports.com
>
>
>
>
Jul 16 '06 #6
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_On End" 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_On End" 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/...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/subscripti...ult.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/subscripti...t/default.aspx.

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

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

Jul 17 '06 #7
Glad to see you again. How are you doing recently?

Life is good - very busy but very good.

--
thanks - dave
david_at_windwa rd_dot_net
http://www.windwardreports.com

"Steven Cheng[MSFT]" wrote:
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_On End" 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_On End" 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/...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/subscripti...ult.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/subscripti...t/default.aspx.

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

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

Jul 17 '06 #8
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_windwa rd_dot_net
http://www.windwardreports.com

"Steven Cheng[MSFT]" wrote:
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_On End" 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_On End" 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/...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/subscripti...ult.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/subscripti...t/default.aspx.

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

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

Jul 17 '06 #9
Thanks for your quick response Dave,

I agree that timestamp approach will have such drawbacks, however, if you
will use "Session_On End" 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

Jul 17 '06 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
9507
by: MostlyH2O | last post by:
Hi Folks, I'm having a hard time getting my Session_OnEnd event to fire in my global.asa. Here's what I have: <SCRIPT LANGUAGE=VBSCRIPT RUNAT=Server> SUB Session_OnStart Session.TimeOut = 30 END SUB
3
3055
by: Tom Bates | last post by:
I can successfully delete files using fso.DeleteFile when in an ASP script. But in Session_OnEnd, where I'd *really* like to clean up files, it appears that DeleteFile doesn't work. I've tried every combination I could think of. I've verified the filespecs I'm using by logging to a session log file. BTW, I found out the hard way that I...
1
2463
by: Soha El-Saeed | last post by:
Dear All; I wrote this code in the global.asa but it dosen't work inspite that it works in any asp file and also in the global.asa file but only in the session_onstart part.This code is to delete a txt file at the end of the session.The file was created during the user's session and has the name of the session id. The session variable...
3
3698
by: cab | last post by:
i have the following code in the "Sub Session_OnEnd" routine that does not seem to run..... Sub Session_OnEnd strConnect = "Driver={SQL Server};Server=SERVER;Database=database; User ID=xxxxxx;Pwd=xxxxxxx" Set objConnEnd = Server.CreateObject("ADODB.Connection") objConnEnd.Open strConnect
24
2440
by: Nancy Drew | last post by:
hi all i'm trying to keep users from being able to login to a site twice at the same time. everytime a user does a login, i stick their userID into an application scoped array. if they try to login again, i bounce them to an error page. i use the session_onEnd sub within global.asa to remove their userID from the array at the end of their...
6
1882
by: Olivier SOW | last post by:
Hi, I have this code in the global.asa file: Sub Session_OnEnd() Set oFso= CreateObject("Scripting.FileSystemObject") Set oFileTxt= oFso.OpenTextFile("c:\debugS.txt", 8, true) oFileTxt.WriteLine Now()&" SESSION END "&session.sessionId Set oFso= nothing: Set oFileTxt= nothing
4
2566
by: anand | last post by:
In my website i want to trace the event when user log off from the site by closing the explorer so i am unable to run any server side program at that time and my session_onend event also not working can any one tell me why the session_onend is not working. Thanx in advance
6
1771
by: Hans Kesting | last post by:
Hi, When the Session_OnEnd event fires, do the Session variables still exist? I want to do some cleanup (update some records in a database etc.), but then I need to know *which* recopds to update ... Can I access these session variables through HttpContext.Current.Session ? (the cleanup-code is in a separate class, which is defined within...
4
1634
by: Chris Ashley | last post by:
There seem to be isolated occurences of Session_OnEnd not firing in my app. This is problematic because some clean up of resources happens here. I know the Session events were unreliable in classic ASP, but is this still the case in ASP.Net? What kind of scenarios would case Session_OnEnd not to fire? Would Application_Error being hit cause...
0
7658
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7579
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7877
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8101
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
5479
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5204
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3615
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2077
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1194
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.