Creating Specialized Session State Store

Discussion in 'ASP .Net' started by Michael O'Brien, Feb 23, 2004.

  1. I'm trying to hook in a specialized state store server into ASP.NET.

    I understand I can create a HttpModule and hook the events
    OnAcquireState and OnReleaseState. So far so good.

    But, it seems that the framework owns the HttpSessionState instance
    (HttpContext.Session) and so my state store module must use the Add,
    Remove and Clear methods to interact with the store. ie. on Acquire, I
    need to call HttpSessionState.Add to add all the persisted state
    variables into HttpSessionState and on Release, I need to persist the
    state from HttpSessionState back to my store. To do this I can just
    use the indexer in HttpSessionState.

    But this is going to be slow as I will be saving and restoring the
    entire session state. If the session state is very large, I wan't to
    only persist those items that have changed. I could keep a copy and
    compare what has changed, but that will be 2x the session data and is
    also an overhead.

    What I'd really like is a lower level interface so that I could only
    save session state items that have changed and not have to serialize
    the entire state on Release. Since HttpSessionState owns the in-memory
    session state dictionary, I can't see how I can do this. I'd really
    like to create my own HttpsessionState instance and control every
    set/get to the HttpSessionState. To do this I need to set the instance
    pointer in HttpContext. I'd like to do this in my module's
    BeginRequest event. But, the problem is there is no SetSession method
    in HttpContext to use.

    Any ideas ?
     
    Michael O'Brien, Feb 23, 2004
    #1
    1. Advertising

  2. Your post went unanswered. Have you resolved this issue?

    --
    Regards,
    Alvin Bruney [ASP.NET MVP]
    Got tidbits? Get it here...
    http://tinyurl.com/3he3b
    "Michael O'Brien" <> wrote in message
    news:...
    > I'm trying to hook in a specialized state store server into ASP.NET.
    >
    > I understand I can create a HttpModule and hook the events
    > OnAcquireState and OnReleaseState. So far so good.
    >
    > But, it seems that the framework owns the HttpSessionState instance
    > (HttpContext.Session) and so my state store module must use the Add,
    > Remove and Clear methods to interact with the store. ie. on Acquire, I
    > need to call HttpSessionState.Add to add all the persisted state
    > variables into HttpSessionState and on Release, I need to persist the
    > state from HttpSessionState back to my store. To do this I can just
    > use the indexer in HttpSessionState.
    >
    > But this is going to be slow as I will be saving and restoring the
    > entire session state. If the session state is very large, I wan't to
    > only persist those items that have changed. I could keep a copy and
    > compare what has changed, but that will be 2x the session data and is
    > also an overhead.
    >
    > What I'd really like is a lower level interface so that I could only
    > save session state items that have changed and not have to serialize
    > the entire state on Release. Since HttpSessionState owns the in-memory
    > session state dictionary, I can't see how I can do this. I'd really
    > like to create my own HttpsessionState instance and control every
    > set/get to the HttpSessionState. To do this I need to set the instance
    > pointer in HttpContext. I'd like to do this in my module's
    > BeginRequest event. But, the problem is there is no SetSession method
    > in HttpContext to use.
    >
    > Any ideas ?
     
    Alvin Bruney [MVP], Mar 2, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. shamanthakamani
    Replies:
    1
    Views:
    3,549
    Natty Gur
    Nov 20, 2003
  2. Not Liking Dot Net Today
    Replies:
    0
    Views:
    672
    Not Liking Dot Net Today
    Apr 21, 2004
  3. Maciek
    Replies:
    0
    Views:
    8,306
    Maciek
    Sep 15, 2005
  4. jnickfl1
    Replies:
    0
    Views:
    631
    jnickfl1
    Sep 18, 2006
  5. Harry Haller
    Replies:
    0
    Views:
    1,686
    Harry Haller
    Nov 7, 2006
Loading...

Share This Page