ASP.NET系统退出(移除Session 、清除浏览器缓存)
生活随笔
收集整理的這篇文章主要介紹了
ASP.NET系统退出(移除Session 、清除浏览器缓存)
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
一、在退出時移除Session,首先在登錄時要記錄登錄信息
Session["id"] = user.id.ToString();Session["name"] = user.name.ToString();Session["pwd"] = user.password.ToString();Session["time"] = user.LoginTime.ToString();Session["limit"] = user.limits.ToString();二、當點擊退出系統時,移除Session,清除緩存
public void Clear(object sender, EventArgs e){Session["id"] = null;Session["name"] = null;Session["pwd"] = null;Session["time"] = null;Session["limit"] = null;ClearClientPageCache();Response.Redirect("~/Login.html");}public void ClearClientPageCache(){//清除瀏覽器緩存Response.Buffer = true;Response.ExpiresAbsolute = DateTime.Now.AddDays(-1);Response.Cache.SetExpires(DateTime.Now.AddDays(-1));Response.Expires = 0;Response.CacheControl = "no-cache";Response.Cache.SetNoStore();}三、
<a target="_self" runat="server" onserverclick ="Clear" >退出</a>?
?
?
?
轉載于:https://www.cnblogs.com/happylzh/p/7007332.html
總結
以上是生活随笔為你收集整理的ASP.NET系统退出(移除Session 、清除浏览器缓存)的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 代码实现:给一个不多于5位的正整数,要求
- 下一篇: asp.net ajax控件工具集 Au