如何正确退出 [英] how to proper log out
本文介绍了如何正确退出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我是一个更新鲜的人。我正在尝试开发一个ASP.NET网站,但我无法正常注销。
当我注销
我们的页面然后它去了到退出
但是我点击浏览器的后退按钮然后再打开上一页
所以请任何人帮我。
我在下面编写的代码。
我在 login.cs上使用此代码
I am a fresher. I am trying to developed a ASP.NET web site but I am not able to do proper logout.
When I logout
our page then it go to logout
but I click on back button of browser then again open previous page
So plz any body help me.
My written code below.
I use this code on login.cs
try
{
if (dt.Rows.Count > 0)
{
Session["Login"] = true;
Session["UserName"] = dt.Rows[0]["UserName"].ToString();
username = dt.Rows[0]["UserName"].ToString();
}
else
{
Response.Write("<Script>alert('data is not match');window.location.href='stafflogin.aspx';</Script>");
}
}
catch
{
}
finally
{
response.Redirect("Default.aspx");
}
和退出
页
and logout
page
protected void logout_Click(object sender, EventArgs e)
{
Session["Login"] = false;
Session.RemoveAll();
Response.Redirect("~/stafflogin.aspx");
}
推荐答案
CodeProject中的常见问题
参考:
退出后的浏览器后退按钮问题 [ ^ ]
退出后浏览器返回按钮问题 [ ^ ]
及更多此处 [ ^ ]
Frequent Question in CodeProject
Refer:
Browser Back Button Issue After Logout[^]
Browser back button issue after logout[^]
and more here[^]
这篇关于如何正确退出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文