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

前端 未结 2 597
死守一世寂寞
死守一世寂寞 2021-01-14 01:39

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

Why I won

相关标签:
2条回答
  • 2021-01-14 02:03

    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.

    0 讨论(0)
  • 2021-01-14 02:23

    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 讨论(0)
提交回复
热议问题