asp.net中的会话注销
问题描述:
我有一个登录页面(default.aspx),然后是2个asp.net页面(page1.aspx,page2.aspx)在带有注销按钮的母版页下.当我单击注销时,它使会话为空,因此注销.
I have a login page(default.aspx) followed by 2 asp.net pages(page1.aspx,page2.aspx) under a masterpage with logout button. When I click logout,it makes the session null and hence logout.
但是注销后,当我将page1.aspx的网址放入地址栏中时,它将再次显示该页面(page1.aspx).
But after logging out when I put the url of page1.aspx in the address bar, it displays the page(page1.aspx) again.
我的注销按钮代码:
Session["id"] = null;
Response.Redirect("Default.aspx");
Response.Cache.SetNoStore();
Response.CacheControl = "no-cache";
答
您必须使用会话放弃方法会话放弃Session.Abandon()
you have to use session abandon method Session abandon Session.Abandon ()