2014-02-27 277 views
0

我有一個登錄頁面,當通過身份驗證後返回到此頁面的已通過身份驗證的用戶時,我希望他們自己重新進行身份驗證。現在,這是我的:重置身份驗證Cookie

protected void Page_Init(object sender, EventArgs e) 
{ 
    HttpContext.Current.Response.Cache.SetCacheability(HttpCacheability.NoCache); 

    if (User.Identity.IsAuthenticated) 
    { 
     var authenticationManager = HttpContext.Current.GetOwinContext().Authentication; 
     authenticationManager.SignOut(); 
    } 
} 

我該如何清除身份驗證cookie並設置一個新的?我正在使用身份驗證。

謝謝。

回答

1

要刪除一個cookie,您將它的過期日期設置爲過去的某個時間。如果您想要替換cookie,只需存儲一個具有相同名稱的新cookie。 More about cookies