我正在使用一個ASP.net MVC3.0應用程序,並保留當前HttpContext會話中的當前用戶信息。HttpContext.Current.Session混淆在Asp.net MVC 3.0
據我所知HttpContext.Current是每當前request.Therefore,我的會話數據應該在新request.However清除後,我可以收到當前用戶會話從數據請求通過存儲HttpContext.Current要求。爲了理解MVC 3.0中的會話管理,我做了這個樣本用於測試目的。
我的問題:如何在當前請求後接收會話數據?我非常感謝你的幫助。
public static UserAccountDto CurrentUser
{
get
{
if (HttpContext.Current == null)
return null;
if (HttpContext.Current.Session[CurrentUserSessionVariable] != null)
return HttpContext.Current.Session[CurrentUserSessionVariable] as UserAccountDto;
return null;
}
private set { HttpContext.Current.Session[CurrentUserSessionVariable] = value; }
}
。 http://msdn.microsoft.com/en-us/library/system.web.httpcontext.current.aspx ...我很困惑。 – marvelTracker
是的,但是這個_並不意味着如果你在兩個不同的請求中得到它,裏面的一切都與以前完全不同! –
嗯..我同意了。謝謝 – marvelTracker