【发布时间】:2012-07-14 19:02:38
【问题描述】:
我有一个具有以下两种方法的 .Net Web 服务:
[WebMethod(EnableSession = true)]
public void A()
{
HttpSessionState session = Session;
Thread thread = new Thread(B);
thread.Start();
}
[WebMethod(EnableSession = true)]
public void B()
{
HttpSessionState session = Session;
}
场景1)当我直接调用B方法时,session不为空
场景 2) 但是当我调用 A 时,在 B 中 session 和 HttpContext.Current 都是 null。
为什么?如何在第二种情况下启用 B 中的会话?如何访问 A 中的会话?我应该将其会话传递给 B 吗?如果是怎么办?
方法 B 不应该有会话作为参数。
谢谢,
【问题讨论】:
标签: c# .net web-services session