从网站注销的代码 [英] code for logout from website

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

问题描述

你好先生,

我已经编写了注销代码,但是当我点击后退按钮时它会加载上一页。所以请告诉我应该怎么做才能纠正这个错误



protected void Page_Load(object sender,EventArgs e)

{

Session.abo();

Session.Contents.RemoveAll();

Response.Redirect(" login.aspx");

}

hello sir,
i have wrote the code for logout but still when i click back button it loads the previous page. so please tell me what should be done to correct this mistake

protected void Page_Load(object sender, EventArgs e)
{
Session.abo();
Session.Contents.RemoveAll();
Response.Redirect("login.aspx");
}

推荐答案

这是正常行为,浏览器显示页面的缓存版本。您必须在网站页面上禁用缓存以停止此操作,这会对性能和资源产生影响,只是为了阻止某人看到他们在5秒前看到的内容。
This is normal behaviour, the browser is showing a cached version of the page. You would have to disable caching on your site pages to stop this which would have an impact on performance and resources, simply to stop someone seeing something they have just seen 5 seconds before.


会话仅删除会话变量和数据,但不删除浏览器的历史记录。您所看到的是前一段时间加载的页面。



您需要的是从浏览器中删除历史记录。 此问题存在类似的问题[ ^ ],请阅读问题。 ASP.NET论坛还有另一个帖子,你应该阅读那个 [ ^ 也是..



否则,只有在应用程序中有特定cookie时才更改应用程序的体系结构并加载内容,如果cookie不可用(删除)然后你不应该加载数据。您可以;这样,当用户注销时删除cookie,因此,当再次加载页面时,cookie不可用,因此数据将不再可用。
The session removes only the session variables, and the data but does not delete the history of the browser. What you're seeing is the page that was loaded a while ago.

What you need is to remove the history from the browser. There has been a similar problem on this question[^], please read the question. There is another thread from ASP.NET forums, you should read that one[^] too..

Otherwise, change the architecture of your application and load the content only when a specific cookie is available in your application, if the cookie isn't available (deleted) then you shouldn't load the data. You can; in this way, delete the cookie when the user logs out and thus, when the page is again loaded the cookie isn't available and thus the data won't be available any more.


这篇关于从网站注销的代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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