If you have not changed the thread, you can use HttpContext.Current.Session , as indicated in the jwwishart file.
HttpContext.Current returns the context associated with the stream. Obviously, this means that you cannot use it, for example, if you started a new thread. You may also need to consider thread flexibility β ASP.NET requests are not always executed on the same thread for the entire request. I believe the context is promoted appropriately, but there is something to keep in mind.
On the other hand, I'm not sure if you even have a session for the AJAX page method. You can try, but I would be a little nervous about it. Ideally, you should pass on all the information you need from the client.
Jon Skeet Apr 05 2018-10-10T00: 00Z
source share