使用asp.net保护c#注销的代码 [英] code to secure logout in c# using asp.net

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

问题描述

我使用以下代码注销我的项目



protected void LinkBut​​ton11_Click(object sender,EventArgs e)

{

Session.Abandon();

Session.Clear();



Response.Redirect(LOGIN .aspx,true);



}



我想阻止用户查看以前的内容注销后使用Back

按钮的页面。我希望显示此页面已过期。

我该怎么做?但我不能通过这段代码来做...



我错过了什么或做错了什么?

解决方案

< blockquote>清理缓存可能有帮助。

在页面加载时尝试这个 -

 Response.Cache.SetAllowResponseInBrowserHistory( False 
Response.Cache.SetCacheability(HttpCacheability.NoCache)
Response.Cache.SetExpires(Now()。AddSeconds(-1))
响应。 Cache.SetNoStore()
Response.AddHeader( Pragma no-cache
Response.Write( & DateTime.Now.ToLongTimeString())


I am using the below code to log out in my project

protected void LinkButton11_Click(object sender, EventArgs e)
{
Session.Abandon();
Session.Clear();

Response.Redirect("LOGIN.aspx",true);

}

I want to prevent the user from viewing the previous page using the Back
button after logout. I want to instead show that this page has expired.
How do I do this? but I cant do it by this code...

What am I missing or doing wrong?

解决方案

Clean the cache might help.
Try this on page load -

Response.Cache.SetAllowResponseInBrowserHistory(False)
Response.Cache.SetCacheability(HttpCacheability.NoCache)
Response.Cache.SetExpires(Now().AddSeconds(-1))
Response.Cache.SetNoStore()
Response.AddHeader("Pragma", "no-cache")
Response.Write("" & DateTime.Now.ToLongTimeString())


这篇关于使用asp.net保护c#注销的代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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