I want to kick off a background worker thread from a client AJAX request. So the request returns immediately and the background thread handles the processing. Is Session state available to this background thread?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Yes – if your background thread is running in the same AppDomain as an ASP.NET site.
HttpContext.Current.Sessionwill get you access to it. Ignoring of course an entire topic of how to best handle multi-threading in web apps, how to best handle injecting dependencies into your backend code (whether a controller or some other technology du jour) for testability, this will get you there quickest and dirtiest.