当我们点击浏览器后退按钮时,如何在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