【发布时间】:2016-05-11 16:14:39
【问题描述】:
我正在用 ASP.NET(框架 4.0)创建一个网站。我在这个网站上保持了会话。我已经编写了注销代码,其中 FormsAuthentication ,会话值为 Abandon 。我的代码如下注销按钮点击。
protected void LinkButton1_Click(object sender, EventArgs e)
{
if (Request.Cookies["ASP.NET_SessionId"] != null)
{
Response.Cookies["ASP.NET_SessionId"].Value = string.Empty;
Response.Cookies["ASP.NET_SessionId"].Expires = DateTime.Now.AddMonths(-20);
}
FormsAuthentication.SignOut();
Session.Abandon();
Response.Redirect(FormsAuthentication.DefaultUrl);
}
如何在注销且没有 javascript 的情况下禁用/阻止/防止到上一页。 因为当用户注销时,他会重定向到默认页面,但用户单击浏览器后退按钮,他会重定向到上一页(即用户主页)而不是登录页面。
【问题讨论】:
标签: javascript c# asp.net session