Session concurrency

Last post 05-13-2008 5:00 PM by RAD1UM. 2 replies.

Sort Posts:

  • Session concurrency

    05-13-2008, 4:32 PM
    • Loading...
    • RAD1UM
    • Joined on 01-15-2008, 2:23 AM
    • Posts 40

    Let's say I collect all session (HttpSessionState) objects by putting them in a collection in my global.asax file.

    Naturally "webpage1" accesses it's own session object "session1",

    but what if a second "webpage2" would need to check something in webpage1's session object.

    Do i have to lock {} the session objects?

    If not how is the synchronization implemented/solved?

     

    Regards

    R4DIUM

    Filed under:
  • Re: Session concurrency

    05-13-2008, 4:36 PM
    • Loading...
    • vcsjones
    • Joined on 04-18-2006, 8:53 PM
    • Falls Church, VA
    • Posts 3,989
    • Moderator
      TrustedFriends-MVPs

     In short (supposing you are using InProc Session State) it is already thread safe. This forum post does a reasonable explanation as to how:

    http://www.velocityreviews.com/forums/t99444-is-access-to-the-session-threadsafe.html

    Cheers,
           Kevin Jones


  • Re: Session concurrency

    05-13-2008, 5:00 PM
    • Loading...
    • RAD1UM
    • Joined on 01-15-2008, 2:23 AM
    • Posts 40

    I read the post, but in my opinion it is not applicaple to my question.

    The post argues that requests coming in under the same SessionID get serialized automatically.

    An example would be two page requests or webmethod calls originating from different registercards running under the same session in IE.

     

    Now, what if two webmethod calls (let's name them 1 and 2) from different computers and thus SessionIDs (1 and 2) begin execution on server concurrently.

    The webmethod 2 get's a reference to Session 1 through a collection where references to all session objects are stored and accesses some objects and variables in it.

    Am I right that this case must be secured separatly though locks{}?

     

    Thx

     

    R4DIUM

Page 1 of 1 (3 items)
Microsoft Communities
Page view counter