开发者

Preserve Session Variables Across HttpHandlers

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?


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜