views:

32

answers:

1

I have an ASP.NET application with 5 .ashx HTTPHandlers that implement IRequiresSessionState or IReadOnlySessionState.

Upon calling the first handler I create a variable and store it in the session.

When I call the next HttpHandler the variable is not available in the session object.

I am use context.Session.

I have a global.asax where I retrieve the sessionId.

Is there a way to preserve session variables across HttpHandlers or does each Handler get its own session?

A: 

HeartAttack has a good discussion of this here:

http://weblogs.asp.net/ashicmahtab/archive/2008/09/18/how-to-use-session-values-in-an-httphandler.aspx

Basically, you need to do something like:

public class MyHandler:IHttpHandler,IRequiresSessionState

HTH's.

This should maintain session state across handlers. That is, when you log in, you only have one session for all of your requests into that domain. I'd suggest verifying that you are really logged in. Cache of course will work because that is common to all sessions but much more expensive on the server because it does not easily go away.

Peter Kellner
I'm already inheriting IRequiresSessionState. What I want is to preserve Session values across HTTPHandlers, because every request to an HTTPHandler gets a new session. Basically I've settled on using the Application Cache instead.
User48765902