473,498 Members | 1,725 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Finding out which sessions are still active

Hi,

I am wondering what is the best way to find out which ASP.NET sessions
are still active.

Here is the reason: I have a custom control which can upload files. It
saves the files in a folder named after the SessionID. At Session_End, I
do some cleanup and delete the "session folder". However, if the PC is
rebooted before the session times out, the clean up never happens. So
what I wanted to do isL: In my CleanUp method, check all other folders.
If the Session is still active, leave them untouched. If the Session has
expired already, delete the folders.

What would be the best way to solve this problem?

Thanks a lot,
Laurent
--
Laurent Bugnion, GalaSoft
Software engineering: http://www.galasoft-LB.ch
Private/Malaysia: http://mypage.bluewin.ch/lbugnion
Support children in Calcutta: http://www.calcutta-espoir.ch
Jan 23 '06 #1
9 2286
Save the current time on each request within a name/value collection (as
key use the sessionid) every directory associated to an entry containing
a date < DateTime.Now.AddMinutes(-20) can be deleted.

--Daniel
http://staff.newtelligence.com/danielf/


-----Original Message-----
From: Laurent Bugnion [mailto:ga*********@bluewin.ch]
Posted At: Monday, January 23, 2006 12:45 PM
Posted To: microsoft.public.dotnet.framework.aspnet
Conversation: Finding out which sessions are still active
Subject: Finding out which sessions are still active

Hi,

I am wondering what is the best way to find out which ASP.NET sessions
are still active.

Here is the reason: I have a custom control which can upload files. It
saves the files in a folder named after the SessionID. At Session_End, I

do some cleanup and delete the "session folder". However, if the PC is
rebooted before the session times out, the clean up never happens. So
what I wanted to do isL: In my CleanUp method, check all other folders.
If the Session is still active, leave them untouched. If the Session has

expired already, delete the folders.

What would be the best way to solve this problem?

Thanks a lot,
Laurent
--
Laurent Bugnion, GalaSoft
Software engineering: http://www.galasoft-LB.ch
Private/Malaysia: http://mypage.bluewin.ch/lbugnion
Support children in Calcutta: http://www.calcutta-espoir.ch

Jan 23 '06 #2
Hi,

Daniel Fisher(lennybacon) wrote:
Save the current time on each request within a name/value collection (as
key use the sessionid) every directory associated to an entry containing
a date < DateTime.Now.AddMinutes(-20) can be deleted.

--Daniel
http://staff.newtelligence.com/danielf/


I was thinking of a more or less similar solution too. However, I read
that there is a way to get the Session objects from the Cache object,
did anyone try that already? Seems that it is not fully documented,
which leads me to think that it's probably not the best way to handle
this...

Thanks,
Laurent
--
Laurent Bugnion, GalaSoft
Software engineering: http://www.galasoft-LB.ch
Private/Malaysia: http://mypage.bluewin.ch/lbugnion
Support children in Calcutta: http://www.calcutta-espoir.ch
Jan 23 '06 #3
Hi,

Spam Catcher wrote:
Laurent Bugnion <ga*********@bluewin.ch> wrote in news:dr2kl0$o2b$1
@zrha118x.zrh.siemens.ch:

I was thinking of a more or less similar solution too. However, I read
that there is a way to get the Session objects from the Cache object,
did anyone try that already? Seems that it is not fully documented,
which leads me to think that it's probably not the best way to handle
this...

I think you can only access the current session object - not all the
session object.


I used to think so too, but this article made me think differently:

http://www.developer.com/net/asp/art...0917_2206351_2
(see point #2).

Got to try this tonight...

Laurent
--
Laurent Bugnion, GalaSoft
Software engineering: http://www.galasoft-LB.ch
Private/Malaysia: http://mypage.bluewin.ch/lbugnion
Support children in Calcutta: http://www.calcutta-espoir.ch
Jan 23 '06 #4
You could just register those IDs in an application variable.

My personal preference would be to just not use those temp directories If
you need to create/delete dirs this is likely because those files are then
placed somewhere else. You could perhaps save them directly at their final
location ?

You could also cleanup those directories based on their age.

--
Patrice

"Laurent Bugnion" <ga*********@bluewin.ch> a écrit dans le message de
news:dr**********@zrha118x.zrh.siemens.ch...
Hi,

Spam Catcher wrote:
Laurent Bugnion <ga*********@bluewin.ch> wrote in news:dr2kl0$o2b$1
@zrha118x.zrh.siemens.ch:

I was thinking of a more or less similar solution too. However, I read
that there is a way to get the Session objects from the Cache object,
did anyone try that already? Seems that it is not fully documented,
which leads me to think that it's probably not the best way to handle
this...

I think you can only access the current session object - not all the
session object.


I used to think so too, but this article made me think differently:

http://www.developer.com/net/asp/art...0917_2206351_2
(see point #2).

Got to try this tonight...

Laurent
--
Laurent Bugnion, GalaSoft
Software engineering: http://www.galasoft-LB.ch
Private/Malaysia: http://mypage.bluewin.ch/lbugnion
Support children in Calcutta: http://www.calcutta-espoir.ch

Jan 23 '06 #5
Hi,

Patrice wrote:
You could just register those IDs in an application variable.
My idea, exactly. If the server reboots, the IDs will be removed from
the Application object, meaning that the sessions have been terminated.
I was just letting my mind wander about other possible implementations.

My personal preference would be to just not use those temp directories If
you need to create/delete dirs this is likely because those files are then
placed somewhere else. You could perhaps save them directly at their final
location ?
Actually, the files are uploaded by the user, then I parse them, modify
them and then offer the modified files for download. Thus the need to
let these directories live for a while.

You could also cleanup those directories based on their age.


I thought of it too, but would like to avoid this. We have sessions
which can last pretty long (days), and others very short. No way to know
when the directory should be deleted based on age only.

Thanks for the input,
Laurent
--
Laurent Bugnion, GalaSoft
Software engineering: http://www.galasoft-LB.ch
Private/Malaysia: http://mypage.bluewin.ch/lbugnion
Support children in Calcutta: http://www.calcutta-espoir.ch
Jan 23 '06 #6
>> I think you can only access the current session object - not all the
session object.


I used to think so too, but this article made me think differently:

http://www.developer.com/net/asp/art...0917_2206351_2
(see point #2).


I think you missed the part of the article that says "This potential
vulnerability has been cleared in version 1.1."

Jan 24 '06 #7
Hi,

Oc******@gmail.com wrote:
I think you can only access the current session object - not all the
session object.


I used to think so too, but this article made me think differently:

http://www.developer.com/net/asp/art...0917_2206351_2
(see point #2).

I think you missed the part of the article that says "This potential
vulnerability has been cleared in version 1.1."


The mentioned vulnerability is that you can enumerate private members of
the Cache object in 1.0. In 1.1 you can only enumerate public members.
However, the article doesn't precise if the Sessions are public or
private members, and thus if they can still be listed in 1.1. Hence my
question.

Anyway I chose another approach.

Thanks anyway,
Laurent
--
Laurent Bugnion, GalaSoft
Software engineering: http://www.galasoft-LB.ch
Private/Malaysia: http://mypage.bluewin.ch/lbugnion
Support children in Calcutta: http://www.calcutta-espoir.ch
Jan 24 '06 #8
It may be more prudent to let a db table help you with the cleanup. If
you track the session ID with the login ID, you would be able to tell
when a login ID has acquired a new session ID based folder. This would
tell you that a previously held folder should be dropped. That would
happen whenever a user goes away without 'terminating' their session,
such as a reboot. You could also use a table, session variable or
application variable to keep track of recent session activity. The
nice thing about using an application variable is that it would be
available at a higher level (administrative functions) and not just to
the client. Then you could set up a periodic sweep to delete
unused/inactive folders. If you have sessions that stay open for
extended periods, you may want to employ some type of role-based
security, where only special users could hold a session for more than,
say 30 minutes. Then you could simply clear out session based folders
for normal users that have had no activity in more than 30 minutes.

Jan 24 '06 #9
Be aware of that the application variables get lost if the server
restarts/stops/crashes - I would prefer the database.

--Daniel
http://staff.newtelligence.com/danielf/


-----Original Message-----
From: John.Net [mailto:jo*******@gmail.com]
Posted At: Tuesday, January 24, 2006 3:48 PM
Posted To: microsoft.public.dotnet.framework.aspnet
Conversation: Finding out which sessions are still active
Subject: Re: Finding out which sessions are still active

It may be more prudent to let a db table help you with the cleanup. If
you track the session ID with the login ID, you would be able to tell
when a login ID has acquired a new session ID based folder. This would
tell you that a previously held folder should be dropped. That would
happen whenever a user goes away without 'terminating' their session,
such as a reboot. You could also use a table, session variable or
application variable to keep track of recent session activity. The
nice thing about using an application variable is that it would be
available at a higher level (administrative functions) and not just to
the client. Then you could set up a periodic sweep to delete
unused/inactive folders. If you have sessions that stay open for
extended periods, you may want to employ some type of role-based
security, where only special users could hold a session for more than,
say 30 minutes. Then you could simply clear out session based folders
for normal users that have had no activity in more than 30 minutes.

Jan 24 '06 #10

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

Similar topics

19
7851
by: Jeff Clark | last post by:
Hiya! How would i get this number? thanks!
3
2452
by: Maxime Ducharme | last post by:
Hi group We have a problem with sessions in one of our sites. Sessions are used to store login info & some other infos (no objects are stored in sessions). We are using Windows 2000 Server...
5
3852
by: Gaetan | last post by:
I would like to guarantee that only one session at a time can request exclusive access to an object stored in Application. The ownership of the object must last throughout multiple HTTP requests. ...
2
2305
by: tbone | last post by:
In trying to improve the throughput of a classic ASP app I wrote last year, I added monitoring to the application and session start and end methods. For one, I'm counting the total number of...
1
1790
by: Kevin Jackson | last post by:
Hello, Using any of the ASP.NET session storage techniques, is there a method in one of the HTTP objects that you can get the list of active (not abandoned or timed out) session keys (and maybe...
4
2173
by: kpg | last post by:
Hi all, Ah yes, the age old counting session question. sessionstate mode="InProc" timeout="5" Sub Application_Start() Application("ConcurrentUsers") = 0
2
3541
by: JoeSep | last post by:
Hello, I know that when the SessionState is set to SQL Server (ASP.NET 1.1) these counters in PerfMon are not valued: - Sessions Abandoned - Sessions Active - Sessions Timed Out - Sessions...
2
12133
by: Krish........... | last post by:
Hi all, How to find out no of active sessions (at a time) in the web server.. I dont think handling Session_start and Session_end events are useful for this. Is there any way to find all current...
6
3681
by: bill | last post by:
I have been "Googling" for about an hour and am turning up squat! I just started receiving this error when trying to log into a MS Access database from a vb .net web application. Recycling IIS...
0
7165
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,...
1
6887
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
7379
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
5462
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4910
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...
0
3085
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1419
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
656
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
291
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.