473,498 Members | 310 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_windward_dot_net
http://www.windwardreports.com

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

--
thanks - dave
david_at_windward_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_windward_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**********************************@microsof t.com...
Got it - the Session object appears to still be good at that point.

--
thanks - dave
david_at_windward_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_windward_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_windward_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**********************************@microsof t.com...
Got it - the Session object appears to still be good at that point.

--
thanks - dave
david_at_windward_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_windward_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_windward_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**********************************@microsof t.com...
Got it - the Session object appears to still be good at that point.
>
--
thanks - dave
david_at_windward_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_windward_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_windward_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_windward_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**********************************@microsof t.com...
Got it - the Session object appears to still be good at that point.

--
thanks - dave
david_at_windward_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_windward_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_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/...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_windward_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_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/...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_windward_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_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/...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_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

Jul 17 '06 #10
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.

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

"Steven Cheng[MSFT]" wrote:
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

Jul 17 '06 #11
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.

Jul 18 '06 #12

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

Similar topics

6
9494
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 =...
3
3045
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...
1
2455
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...
3
3685
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...
24
2422
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...
6
1879
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)...
4
2552
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...
6
1761
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...
4
1627
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...
0
6998
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...
0
7163
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,...
0
7200
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...
1
6884
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7375
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
3090
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1416
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 ...
1
651
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
287
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.