Is it possible to enumerate sessions for an application?

G

Gaetan

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.

However the session might timeout.

When a session ask ownership of the object, I need to determine whether the session that
currently own it is still active. I need to enumerate the sessions for the current
application to determine whether to previously assigned ownership is still valid.

Hence my question: Is it possible to enumerate sessions for an application?
 
G

Gaetan

In the event it is not possible to enumerate the active sessions, is there a mechanism in
IIS 6 where I can query whether a given SessionID is valid?
 
B

Bruce Barker

the common approach is to track sessions is to keep a hashtable of sessions,
add on seassionstart, remove on sessionend.

-- bruce (sqlwork.com)
 
G

Gaetan

That would be a logical approach but many articles on MSDN and even in this newsgroup
suggest that Session_End() is not always invoked when a session ends.
 
S

shiv_koirala

If you are talking only about enumeration
NameObjectCollectionBase.KeysCollection keys = Session.Keys;
foreach (string key in keys)
{
// Session[key] returns the item's value
}

Now if you need to track whether the sessions are active or not you
have to think of some cryptic logic. This what i had done for a chat
application. I pinged the server in regulare intervals and in every
ping i updated the time. So if the time intervals are minimum that
means that session is active or else its not. For web based application
you can make a small hidden fram and trip the server in regulare
intervals.....I know it will increase traffic ... Any more suggestion i
would like to track this thread
-------
Regards ,
C#, VB.NET , SQL SERVER , UML , DESIGN Patterns Interview question book
http://www.geocities.com/dotnetinterviews/
My Interview Blog
http://spaces.msn.com/members/dotnetinterviews/
 
G

Gaetan

What I am trying to achieve here is to obtain the list of SessionID for the application;
not the keys that have been defined in my own session.

If there are 5 connected users wo my web site, I would like to obtain the 5 SessionID
values.
 

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,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top