asp.net处理后退按钮事件后退出 [英] asp.net handling Back button event after Logout

查看:196
本文介绍了asp.net处理后退按钮事件后退出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在注销链接按钮单击事件我已清除会话变量。我在每个页面的加载事件检查空值这些会话变量。如果是空值将其重定向到登录页面。
但问题是,每当我点击浏览器后退按钮,在Page_Load事件将不会被调用。对于我已清除浏览器缓存的历史。
请帮我有人在那里我失踪...

In the logout link button click event I have cleared the session variables. I am checking these session variables for null values at each page's load event. If it has the null value redirecting them to the login page. But the problem is whenever I click the browser back button, the page_load event won't get called. For that I have cleared the the browser cache history. Please help me someone where I am missing...

推荐答案

您需要确保登录后的页面(那些只能登录后可以访问)在浏览器不会被缓存:

You will need to make sure the pages behind the login (those that can only be accessed after login) are not cached in the browser:

Page.Response.Cache.SetCacheability(HttpCacheability.NoCache);

如果使用窗体身份验证,则还需要摒弃了会议,并注销:

If using forms authentication, you will also need to abandon the session and logout:

Session.Abandon();
FormsAuthentication.SignOut();

请参阅this, <一href=\"http://stackoverflow.com/questions/589285/how-to-disable-back-button-in-browser-when-user-logout-in-asp-net-c\">this和<一个href=\"http://stackoverflow.com/questions/2686946/asp-net-authentication-login-and-logout-with-browser-back-button\">this.

这篇关于asp.net处理后退按钮事件后退出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆