退出登录,清除Session
1 protected void Button1_Click(object sender, EventArgs e)
2 {
3 if (Session["UserName"] != null)
4 {
5 Session.Remove("UserName");
6 Session.RemoveAll();
7 Response.Cookies["UserName"].Expires = DateTime.Now;
8 }
9 Page.RegisterStartupScript("","<script>window.top.document.location.href='index.aspx';</script>");
10 }
2 {
3 if (Session["UserName"] != null)
4 {
5 Session.Remove("UserName");
6 Session.RemoveAll();
7 Response.Cookies["UserName"].Expires = DateTime.Now;
8 }
9 Page.RegisterStartupScript("","<script>window.top.document.location.href='index.aspx';</script>");
10 }