2012-12-07 38 views
0

我有兩個處理程序。將Session中的對象保存在ashx處理程序中,並在另一個ashx處理程序中獲取該對象。怎麼樣?

在Authentication.ashx處理程序我保存對象會是這樣的:

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

然後,我還有一個處理程序,Send.ashx我想保存在Authentication.ashx的對象。

我該怎麼做? 我的代碼來獲取對象是:

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

問題: userCache是​​空永諾,我有IRequiresSessionState兩個處理器來實現。

+0

問題是? – usr

+0

對不起,問題在於Send.ashx。變量userCache全爲空。我在兩個處理程序上都實現了接口IRequiresSessionState。 – mrodriguez

+0

使用什麼客戶端技術來訪問? –

回答

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"]; 
} 
0

無論是線路沒有執行

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

,或者用於保存和檢索的字符串鍵是不同的,或者您打電話給

Session.Abandon(); 

這兩個處理程序之間。