2012-03-19 36 views
0

我有一個asp.net web應用程序登錄頁面,它具有內置的身份驗證通過asp.net的Login控制創建的asp.net和login.aspx頁面。現在我註銷時遇到問題。如何在ASP.NET中登錄時終止用戶會話

當用戶按下「註銷」時,鏈接被重定向到「Login.aspx」頁面。但是,當用戶從瀏覽器按下「返回」按鈕時,用戶「登錄」到我想要避開的應用程序的頁面,並且它必須要求輸入登錄憑證。

幫助讚賞..! 感謝Advace ..!

回答

2

你可以,如果你正在使用MasterPage然後在代碼的母版的背後嘗試

protected void btnLogout_Click(object sender, EventArgs e) 
    { 
     Session.RemoveAll(); 
     Session.Abandon(); 

     Response.Redirect("LoginPage.aspx"); 
    } 
+0

感謝答覆..!但是,這不起作用......當他再次按下瀏覽器的「返回」按鈕時,他登錄到網頁。 – 2012-03-19 08:35:58

0

,你可以做到這一點

Response.ExpiresAbsolute = DateTime.Now.AddDays(-1d); 
Response.Expires = -1500; 
Response.CacheControl = "no-cache"; 

也不要忘記清除會話,而註銷。

+0

非常感謝....我會試試這個:-) – 2012-03-19 08:36:20

0

使用下面的代碼:

Session.RemoveAll(); 
FormsAuthentication.SignOut(); 

FormsAuthentication.RedirectToLoginPage();