The ASP.NET ExecutionContext , which is responsible for storing the HttpContext.Current instance, will naturally not spill over into other threads. Judging by your error stack trace, you are running ASP.NET MVC, which abstracts the use of HttpContext . Perhaps you came from the background of WebForms, where its direct use is common?
SynchronizationContext
This article offers much more detail than I can reasonably delve into. Some of the most important questions for your situation:
"ExecutionContext is environmental information, that is, it stores data related to the current environment or" context "in which you work.
This "surrounding" information is ... HttpContext.Current and its various properties (including Session ).
"This means that this surrounding context, which we use to monitor the details of our execution, is no longer viable because TLS does not" flow "through these asynchronous points.
TLS is a stream-local storage ( HttpContext.Current , etc.). In short, async = potentially loses HttpContext.Current .
MVC path
Remember, I said that MVC basically abstracts from HttpContext ?
Session is located in Controller.Session . (I apologize that so far I have not tested this in the action of the asynchronous mode controller, so I cannot yet verify its suitability for your needs or you will need additional work to make it cooperate.)
Request is in Controller.Request
User is in Controller.User
There are others ... check them out .
Session alternatives?
Have you considered alternatives? You don't have to go far to find articles suggesting that Session + ASP.NET MVC is a bad idea. I will not weigh something generalized as βbadβ, but looking at your example, it seems to me that you are dealing with user profile data, not session data.
A session is not really a good place to cache user profile information. In this regard, is it appropriate to cache it at all? Can a user profile change during a session? If they themselves changed it, would you have a reset session? What should I do if an individual admin user changes their profile during login?
Exploring alternatives is beyond the scope of this question, but just be careful that you can solve the wrong problem here.