今天在网上搜索了半天也没有找到好的解决方法,现在用这个基本上可以使用asp.net2.0防后退功能
问题重现:
用户点击登出按钮(button1)后,仍然可以后点击IE上面的后退按扭后退到此页面,并没有RedirectToLoginPage;
解决方法:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class controlCenter_systemMange_Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Response.Cache.SetCacheability(System.Web.HttpCacheability.NoCache);
if (!User.Identity.IsAuthenticated)
FormsAuthentication.RedirectToLoginPage();
}
protected void Button1_Click(object sender, EventArgs e)
{
FormsAuthentication.SignOut();
FormsAuthentication.RedirectToLoginPage();
}
}
本文介绍了一种防止用户在ASP.NET 2.0应用中登出后通过浏览器后退按钮返回登录页面的方法。具体实现包括设置缓存不可用及使用FormsAuthentication进行重定向。

435

被折叠的 条评论
为什么被折叠?



