![](/img/trans.png)
[英]When the same user ID is trying to log in on multiple devices, how do I kill the session on the other device? Asp.net Identity
[英]How to kill the Session of User when he LoggedOut in ASP.NET
我有一個asp.net Web應用程序登錄頁面,它具有asp.net的登錄身份驗證和asp.net的登錄控件創建的login.aspx頁面。 現在我在注銷時遇到了問題。
當用戶按下“注銷”時,鏈接將重定向到“Login.aspx”頁面。 但是,當用戶從瀏覽器按“返回”按鈕時,用戶“登錄”到我要避免的應用程序頁面,並且必須要求輸入登錄憑據。
幫助感謝...! 謝謝Advace ..!
你可以試試
protected void btnLogout_Click(object sender, EventArgs e)
{
Session.RemoveAll();
Session.Abandon();
Response.Redirect("LoginPage.aspx");
}
如果您使用的是MasterPage
那么在您的MasterPage的Code Behind中,您可以執行此操作
Response.ExpiresAbsolute = DateTime.Now.AddDays(-1d);
Response.Expires = -1500;
Response.CacheControl = "no-cache";
另外,請不要忘記在注銷時清除會話。
使用以下代碼:
Session.RemoveAll();
FormsAuthentication.SignOut();
FormsAuthentication.RedirectToLoginPage();
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.