1、在退出時移除Session,首先在登陸時要記錄登陸信息html
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();
2、當點擊退出系統時,移除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(); }
3、緩存
<a target="_self" runat="server" onserverclick ="Clear" >退出</a>