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?

4

2 回答 2

0

显然PageAsyncTask在其构造函数中有一个Object state参数。

在 msdn 上,看起来他们用它来命名他们的任务,但你可以(ab)使用它并把HttpContext.Current.Session它放进去。然后在任务内部,强制转换为会话对象。

注意:说“(ab)use”是因为我不确定状态参数的用途,但它说“代表任务状态的对象”。您可以争辩说当前会话是当前状态的表示。

于 2011-11-07T18:23:30.787 回答
-1

您通常应该能够通过以下方式访问会话:

HttpContext.Current.Session

d。

于 2011-11-07T17:46:53.127 回答