.net中web用session存储的用户退出后,浏览器后退还可以操作一次的问题!

2025-02-22 21:31:31
推荐回答(3个)
回答1:

你只是把Session赋值为null,但当前会话并没有消除!所以你后退还是会进入退出前的页面!!
你要是那样写的话,在每个页面的Page_Load方法中都判断一下Session["Admin"] 是否为空,为空则Response.Redirect("../Login.aspx")。
退出系统时,应该销毁Session:Session.Abandon();

回答2:

设置页面不被缓存
HttpContext.Current.Response.Buffer = true;
HttpContext.Current.Response.ExpiresAbsolute = System.DateTime.Now.AddSeconds(-1);
HttpContext.Current.Response.Expires = 0;
HttpContext.Current.Response.CacheControl = "no-cache";
HttpContext.Current.Response.AddHeader("Pragma", "No-Cache");

回答3:

REF:

使用SCheduler控件实现生产进度监控程序