当我们点击浏览器后退按钮时,如何在asp.net中过期 [英] How to Expire Session in asp.net when we click on browser back button
本文介绍了当我们点击浏览器后退按钮时,如何在asp.net中过期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
点击浏览器后退按钮后,如何在asp.net中使会话失效?就像银行网站一样。
因为我使用普通网页登录,然后从MasterPage我正在使用子页
How to Expire the Session in asp.net when we click on browser back button? Just like Banking web site .
As i'm using Normal web page for login and then from MasterPage i'm using child page
推荐答案
单击注销按钮使会话= null;
When you click Log Out Button make your session =null;
Session["UserName"] = null;
Session["Password"] = null;
此外,你可以做一件事在每个页面加载事件中添加此代码
Also you can do one thing add this code in every page load event
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.Cache.SetExpires(DateTime.Now); //or a date much earlier
这篇关于当我们点击浏览器后退按钮时,如何在asp.net中过期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文