2010-12-10 32 views
3

我有一個註銷操作,它指向一個註銷視圖。點擊註銷按鈕後,用戶信息仍然顯示。我在轉到其他網址後完全註銷,爲什麼?我該如何處理?客戶端重定向?ASP.NET MVC:在視圖中註銷一次被稱爲

操作:

public ViewResult LogOut() 
    { 
     FormsAuthentication.SignOut(); 
     return View(); 
    } 

回答

0

我使用JavaScript事件重定向頁面。

1

嘗試Session.Abandon();註銷後

+0

無法正常工作..信息在渲染後仍然顯示在視圖中。 – 2010-12-10 01:34:01

2

嘗試擺脫認證令牌:

FormsAuthentication.SignOut(); 
Context.Response.Cookies.Item(FormsAuthentication.FormsCookieName).Expires = Date.Now; 
return RedirectToAction("LogOut"); 

此外,確保該頁面沒有被緩存:

Response.Cache.SetExpires(DateTime.UtcNow.AddMinutes(-1)); 
Response.Cache.SetCacheability(HttpCacheability.NoCache); Response.Cache.SetNoStore();