By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,422 Members | 1,297 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,422 IT Pros & Developers. It's quick & easy.

Accessing Session state in Web Service from Background thread

P: n/a
JEB
I know that with Web Services, you should be doing everything in a stateless
environment. However, I have three methods out of over 100 that need state.
I have the client cookie container, WebMethod with Session enabled = true,
the works. However, my issue is I am running logic on a background thread in
a managed thread pool and I cannot access the session. I cannot pass all the
data into the thread either. Is there a way to access
HttpContext.Current.Session from a background thread? Everytime I check the
HttpContext.Current, it is equal to null. Any help is appreciated.
May 17 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
JEB wrote:
I know that with Web Services, you should be doing everything in a
stateless environment. However, I have three methods out of over 100
that need state. I have the client cookie container, WebMethod with
Session enabled = true, the works. However, my issue is I am running
logic on a background thread in a managed thread pool and I cannot
access the session. I cannot pass all the data into the thread
either. Is there a way to access HttpContext.Current.Session from a
background thread? Everytime I check the HttpContext.Current, it is
equal to null. Any help is appreciated.


But then, what is the current session in the background thread? If
there is no request at this time - there is no current session. If
there's two or more concurrent requests, the "current" session is
ambiguous.

What you should do perhaps, is to have an array in a singleton or
static object. When a session starts, add the Session to the array
(using a critical section to protect this code). When a session's done,
throw it out of the array. Access this array from the background
thread, again, through the critical section.
--
Deepak Shenoy
http://shenoyatwork.blogspot.com
May 18 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.