1

I am using the PageAsyncTask object to execute some elements in parallel on a standard ASP.NET page. However I need one task to have access to Http Session. Is there a way to get the Http Session passed to the PageAsyncTask?

Michael Edwards
  • 6,308
  • 6
  • 44
  • 75

2 Answers2

0

apparently a PageAsyncTask has a Object state parameter in its constructor.

On msdn it looks like they use it to name their Task, but you could (ab)use it and just put HttpContext.Current.Session in it. Then inside the task, cast is back to a session object.

Note: saying "(ab)use" because I'm not certain what the state paramater is meant to be used for, but it says "The object that represents the state of the task." You could argue the current session is a representation of the current state.

Ron Sijm
  • 8,490
  • 2
  • 31
  • 48
-1

You should normally be able to access session with:

HttpContext.Current.Session

d.

Didier Ghys
  • 30,396
  • 9
  • 75
  • 81