[英]How to kill the Session of User when he LoggedOut in ASP.NET
I have a asp.net web application login page which has buil-in Authentication of asp.net and login.aspx page created by Login control of asp.net. 我有一个asp.net Web应用程序登录页面,它具有asp.net的登录身份验证和asp.net的登录控件创建的login.aspx页面。 Now i have a problem in logout.
现在我在注销时遇到了问题。
When user pressed "Logout" the link is redirected to "Login.aspx" page. 当用户按下“注销”时,链接将重定向到“Login.aspx”页面。 But, when the user press "Back" button from the browser the user "Login"to the page to the application which i want to avoid and it must ask to enter Login Credentials.
但是,当用户从浏览器按“返回”按钮时,用户“登录”到我要避免的应用程序页面,并且必须要求输入登录凭据。
Help Appreciated..! 帮助感谢...! Thanks in Advace..!
谢谢Advace ..!
you can try 你可以试试
protected void btnLogout_Click(object sender, EventArgs e)
{
Session.RemoveAll();
Session.Abandon();
Response.Redirect("LoginPage.aspx");
}
If you are using MasterPage
then in the Code Behind of your MasterPage, you can do this 如果您使用的是
MasterPage
那么在您的MasterPage的Code Behind中,您可以执行此操作
Response.ExpiresAbsolute = DateTime.Now.AddDays(-1d);
Response.Expires = -1500;
Response.CacheControl = "no-cache";
Also do not forget to clear the Session while Logging off. 另外,请不要忘记在注销时清除会话。
Use the following code: 使用以下代码:
Session.RemoveAll();
FormsAuthentication.SignOut();
FormsAuthentication.RedirectToLoginPage();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.