簡體   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