Creating Specialized Session State Store

M

Michael O'Brien

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 ?
 

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,996
Messages
2,570,238
Members
46,826
Latest member
robinsontor

Latest Threads

Top