[英]ASP.net MVC 5 - How to redirect to action method from from session_end() event in Global.asax.cs
[英]ASP.NET MVC4 - Session_End - How can I get the currently logged on user's name in Session_End of Global.asax?
我的問題是,一旦Session_End在我的Global.asax中執行, HttpContext.Current
對象就不再存在 - 可能正如預期的那樣,我想。 所以,我要做的是一旦會話結束,為當前登錄的用戶更新我的Logins表並將其LoggedIn狀態設置為False。 這是我的Session_End:
protected void Session_End(object sender, EventArgs e)
{
Helpers.OperationContext.UpdateIndividualLogin();
}
你可能猜到,我可以試着傳入:
System.Web.HttpContext.Current.User.Identity.Name
但是這個對象不再存在,因為我只能想象它已經被處理掉了。 那么,有什么方法可以獲取當前(或以前當前)用戶的名字?
您可以通過在Session中存儲所需信息(在本例中為用戶名)來完成此操作。 您可以在用戶通過身份驗證時存儲它。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.