Howt处理用户会话时,单击在ASP.Net浏览器前进或后退按钮? [英] Howt to handle user's session when browser forward or back buttons are clicked in ASP.Net?

查看:89
本文介绍了Howt处理用户会话时,单击在ASP.Net浏览器前进或后退按钮?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在用户登录,在一个网站通过使用他的证件,如果他点击后退按钮的浏览器,并回归到登录页面进行身份验证,那么如何限制用户,当他试图访问与出提供其他页面再次凭据?

After user logs-in to a website by authenticating using his credentials, if he clicks back button in browser and comes back to log-in page, then how to restrict the user when he tries to visit other pages with out providing the credentials again?

推荐答案

每当用户来登录页面,除去身份验证cookie。这种方式,未经认证的cookie,用户将不能够去任何其它页面。

Whenever a user comes to the login page, remove the authentication cookie. This way, without the authentication cookie, the user won't be able to go to any other page.

但是,当用户点击返回按钮,你就必须写在登录页面的Page_Load方法如下code禁用缓存 -

But when the user clicks the back button, you'll have to write the following code in the login page's Page_Load method to disable caching -

Response.AddHeader("Expires", "-1");
Response.AddHeader("Cache-Control", "no-store, no-cache, must-revalidate");
Response.AddHeader("Pragma", "no-cache");

这篇关于Howt处理用户会话时,单击在ASP.Net浏览器前进或后退按钮?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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