繁体   English   中英

在ashx处理程序上的Session中保存对象,并在另一个ashx处理程序中获取对象。 怎么样?

[英]Save object in Session on a ashx handler and get the object in another ashx handler. How?

我有两个处理程序。

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

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

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

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

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

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

我认为它们的意思是Authentication.ashx:

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

在Send.ashx中

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

要么线

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

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

Session.Abandon();

在这两个处理程序之间。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM