C# 注销后会话未过期

C# 注销后会话未过期,c#,asp.net,session-state,C#,Asp.net,Session State,当用户登录时,我在会话中存储用户名和密码。注销后,当我按下浏览器的后退按钮时,它再次进入用户的主页。我希望会话必须过期,以便在用户按“后退”按钮退出后,他可以重新连接到登录页面 我已经试过了 Session.RemoveAll(); Session.Abandon(); Session.Remove("StoreUser"); StoreUser是包含用户名和密码的会话的名称。我使用了FormsAuthentication.SignOut() 在我的Web应用程序的另一个地方,当用户登录时,我

当用户登录时,我在会话中存储用户名和密码。注销后,当我按下浏览器的后退按钮时,它再次进入用户的主页。我希望会话必须过期,以便在用户按“后退”按钮退出后,他可以重新连接到登录页面

我已经试过了

Session.RemoveAll();
Session.Abandon();
Session.Remove("StoreUser");

StoreUser是包含用户名和密码的会话的名称。

我使用了
FormsAuthentication.SignOut()

在我的Web应用程序的另一个地方,当用户登录时,我在我的Web表单上有:

<asp:LoginStatus ID="LoginStatus1" LogoutImageUrl="~/Img/Logout.png" 
    BackColor="Transparent" runat="server" onloggingout="LoginStatus1_LoggingOut" />
当您的注销按钮单击事件时使用,请查看下面的代码

public void LogoutLink_OnClick(object sender, EventArgs args)
{
  FormsAuthentication.SignOut();
  FormsAuthentication.RedirectToLoginPage();
}

请参阅前面的有用讨论:

以下链接可以帮助您-


您的会话正在被清除,但页面的缓存正在存储在客户端。您必须处理该问题。

您可以在用户主页的页面加载事件上编写一个方法,并在该方法中检查会话是否不存在,然后将其重定向到注销页面您在登录时正在检查会话值您是否使用mvc或webforms,是否使用formauth?
## IN Global.asax file you have to clear all the session in Session_end event ##
clear all the session in this event.

     protected void Session_End(object sender, EventArgs e)
{
// Code that runs when a session ends.
// Note: The Session_End event is raised only when the sessionstate mode
// is set to InProc in the Web.config file. If session mode is set to StateServer
// or SQLServer, the event is not raised.

}
## IN Global.asax file you have to clear all the session in Session_end event ##
clear all the session in this event.

     protected void Session_End(object sender, EventArgs e)
{
// Code that runs when a session ends.
// Note: The Session_End event is raised only when the sessionstate mode
// is set to InProc in the Web.config file. If session mode is set to StateServer
// or SQLServer, the event is not raised.

}