Is it possible to enumerate sessions for an application?

Discussion in 'ASP .Net' started by Gaetan, Oct 21, 2005.

  1. Gaetan

    Gaetan Guest

    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?
     
    Gaetan, Oct 21, 2005
    #1
    1. Advertisements

  2. Gaetan

    Gaetan Guest

    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?
     
    Gaetan, Oct 21, 2005
    #2
    1. Advertisements

  3. Gaetan

    Bruce Barker Guest

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

    -- bruce (sqlwork.com)
     
    Bruce Barker, Oct 22, 2005
    #3
  4. Gaetan

    Gaetan Guest

    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.
     
    Gaetan, Oct 22, 2005
    #4
  5. Gaetan

    shiv_koirala Guest

    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/
     
    shiv_koirala, Oct 22, 2005
    #5
  6. Gaetan

    Gaetan Guest

    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.
     
    Gaetan, Oct 23, 2005
    #6
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.