开发者

How to get Session Data with out having HttpContext.Current, by SessionID

I am searching to find a way to read and write on session data but with out having the HttpContext. Current.

Why I won to do that ? because I wish to make some action with the user Session after the page have been close and unloaded.

For example, a user load and see a page, then I create a thread to make some action and let user go. Inside this thread I like to read the session data, but in this case HttpContext . Current is not exist any more.

So is there a way to read Session Data knowing just the session id.

I store my session inside an SQL server, and I see them. its there on table ASPStateTempSessions :)

How can I read them "offline" and manipulate them ?开发者_运维知识库

Thank you in advanced.,


Still not quite clear why you might want to do that but you might not actually need to do it on Session_End(). At that point, it may be too late for you to work with the session data anyway (I've read some articles before about this). What might be a better solution is to actually attempt to work on the session data when your application actually has the context.

For example:

There's nothing to stop your application creating an asynchronous request on a new thread in the background (or even a different application, such as a Windows Service, for instance) when the specific session variable that you want is updated or has been set. This way, your application will be able to access the current HttpContext as well as all of the session data.

Not sure if this helps, but it was worth a shot ;)

Richard.


I may be a little late but... Today I found about the: System.Web.HttpRuntime.Cache

I know is not the same that a session but I think it's much better alternative that db. Regards.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜