asp.net中的注销问题 [英] logout problem in asp.net

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

问题描述

当注销我如何禁用浏览器的返回按钮时..当我点击我的项目中的注销按钮时,我重定向到登录页面但是返回仍然启用,所以没有用...我怎么能解决这个问题..

when loging out how can i disable the go back button of browser..now when i click on the log out button in my project i redirect to log in page but the go back is still enabled and so no use...how can i solve this..

推荐答案

这是因为缓存而发生的。

1.清除会话

2.清除缓存,使浏览器没有历史记录(这将使浏览器中的后退/前进按钮变为灰色禁用。)



清除缓存的代码可以放代码背后的代码如下:

This happens because of cache.
1. clear the sessions
2. clear the cache such that browser has no history (this will make back/forward button in browser grayed out disabled.)

Code for clearing cache can be put up in code behind as follows:
// Code disables caching by browser. Hence the back browser button
// grayed out and could not causes the Page_Load event to fire 
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.Cache.SetExpires(DateTime.UtcNow.AddHours(-1));
Response.Cache.SetNoStore();



如果你想把它放在那里你可以添加类似于aspx的东西:


You can add somethin similar in form aspx if you want to place it there:

<meta http-equiv="Cache-Control" content="no-cache">
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="Expires" content="0"></meta></meta></meta>


您可以使用以下方法删除会话:



Session.Remove(SessionName);





Anurag
You can remove the session by using :

Session.Remove("SessionName");


Anurag


为什么需要禁用后退按钮?如果您已将用户正确登录,则按后退按钮应始终将其返回到登录页面,因为它们的会话不再有效。
Why do you need to disable the back button? If you have properly logged the user out then pressing the back button should always return them to the login page since they're session is no longer valid.


这篇关于asp.net中的注销问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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