登出问题 [英] Logout problem
问题描述
你好,
我正在设计一个网站.除注销方案外,其他一切正常.用户登录网站后,他使用该网站(网站)并注销以返回登录页面,但问题是如果单击返回,则从登录页面退出按钮,再次将其重定向到上次使用的页面.这应该不会发生.该会话仍然存在.我在Logout linkbutton click事件中使用了
Hi there,
I am designing a website.Everything works fine except the logout scenario.After the user login into website,he uses it(website) and does a logout to return to Login page,but the problem is that from login page if I click the back button,again it redirects to the last used page.This should not happen.The session still exists.I used
Session.Abandon();
Response.Redirect("Login.aspx");
.但是问题仍然存在.
还有其他解决方案吗?我可以使用会话超时机制.请让我知道.
谢谢和问候,
S.M. Naresh.
in Logout linkbutton click event.But the problem still exists.
Is there any other solution for this and Can I use Session Timeout mechanisms.Please let me know..
Thanks and Regards,
S.M.Naresh.
推荐答案
由于高速缓存而发生这种情况.
1.清除会话
2.清除缓存,使浏览器没有历史记录(这将使浏览器中的后退/前进"按钮变为灰色).
清除缓存的代码可以放在下面的代码中:
This happens because of cache.
1. clear the sessions
2. clear the cache such that browser has no history (this will make back/forward button in browser grayed out disabled.)
Code for clearing cache can be put up in code behind as follows:
// Code disables caching by browser. Hence the back browser button
// grayed out and could not causes the Page_Load event to fire
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.Cache.SetExpires(DateTime.UtcNow.AddHours(-1));
Response.Cache.SetNoStore();
或
您可以将类似的东西添加为aspx格式:
OR
You can add somethin similar in form aspx if you want to place it there:
<meta http-equiv="Cache-Control" content="no-cache">
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="Expires" content="0"></meta></meta></meta>
或
您可以通过JavaScript清除浏览器历史记录....
OR
You can clear browser history through JavaScript....
//clears browser history and redirects url
<SCRIPT LANGUAGE=javascript> { var Backlen=history.length; history.go(-Backlen); window.location.href=page url }</SCRIPT>
或者如您在登出事件中所说:
OR as you say in you logout event:
protected void LogOut()
{
Session.Abandon();
string nextpage = "Logoutt.aspx";
Response.Write("<script language=javascript>");
Response.Write("{");
Response.Write(" var Backlen=history.length;");
Response.Write(" history.go(-Backlen);");
Response.Write(" window.location.href='" + nextpage + "'; ");
Response.Write("}");
Response.Write("</script>");
}
这篇关于登出问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!