0

我有两个处理程序。

在 Authentication.ashx 处理程序中,我在会话中保存一个对象,如下所示:

HttpContext.Current.Session["ConnectionUserSession"] = userCache;

然后,我有另一个处理程序,Send.ashx,我想获取保存在 Authentication.ashx 中的对象。

我该怎么做?我获取对象的代码是:

UserCache userCache = (UserCache) HttpContext.Current.Session["ConnectionUserSession"];

问题:userCache 始终为空,并且我在两个处理程序上都实现了 IRequiresSessionState。

4

2 回答 2

0

无论是线

HttpContext.Current.Session["ConnectionUserSession"] = userCache;

没有执行,或者用于保存和检索的字符串键不同,或者您调用了

Session.Abandon();

这两个处理程序之间。

于 2012-12-07T15:24:20.023 回答
0

我认为他们的意思是在Authentication.ashx中:

public void ProcessRequest (HttpContext context) {
    context.Session["ConnectionUserSession"] = userCache;
}

在 Send.ashx 中,

public void ProcessRequest (HttpContext context) {
    UserCache userCache = (UserCache) context.Session["ConnectionUserSession"];
}
于 2012-12-07T15:00:15.923 回答