.NET Session Alternative Globally

Quick question: Is there a "per user" data storage object (similar Session) that I can store in a global scope (similar HttpRuntime.Cache)? Almost as if Session, and HttpRuntime.Cachehad a child.

Full background: I have an ASP.NET website that was originally written for a single thread. Now I changed it so that certain actions spawned a background thread, and the browser polled the service to receive status updates.

The problem I am facing is that some pieces of data are stored in the HttpContext.Session [] object (for example, a membership authentication token). These pieces of data must be unique to each user and accessible to the background stream. Session is not available for background thread.

I know HttpRuntime.Cache, but this will require micromanagement to segment users and expire at the same time that the session has expired. SessionOn the other hand, these things automatically expire at the right time, when I also want it, and is already used by such things as SqlMembershipProvider.

My question is: is there something that behaves like a session but exists in a global area?

+3
source share
3 answers

, - , . , :

  • Dictionary . , .
  • , - , , (, ..).
  • , (, )
+3

HttpContext.Current . currentContext.Session, , currentContext HttpContext, .

, HttpContext .

+3

.

, backgound, . , ( ), , - IIS /, .

+3

Source: https://habr.com/ru/post/1794519/


All Articles