2012-03-30 11 views
0

这适用于IE,FireFox和Chrome开发包 - 包括手动删除IE中的Cookie Internet选项 我以用户身份登录,更改密码(工作)并注销。然后我可以使用旧密码和新密码以用户身份登录 - 垃圾密码的身份验证失败。 登录 - 更改密码 - 注销 - 再 登录旧密码,服务器验证 - 注销 - 登录用新密码,服务器验证 - 注销 - 登录与课程 冲洗垃圾密码失败和重复 - 相同的行为 Azure部分是否缺少代码片段?令人不安 - 哎呀 的web.config:MVC3 Azure - 表单身份验证 - 注销失败悲惨 - 我做了一件坏事,坏事

<authentication mode="Forms"> 
    <forms loginUrl="~/Account/LogOn" timeout="15"></forms> 
</authentication> 

签收代码:

public ActionResult LogOff() 
    { 
     FormsAuthentication.SignOut(); 

     // Drop all the information held in the session 
     Session.Clear(); 
     Session.Abandon(); 

     // clear authentication cookie 
     HttpCookie cookie1 = new HttpCookie(FormsAuthentication.FormsCookieName, ""); 
     cookie1.Expires = DateTime.Now.AddYears(-1); 
     Response.Cookies.Add(cookie1); 

     // clear session cookie 
     HttpCookie cookie2 = new HttpCookie("ASP.NET_SessionId", ""); 
     cookie2.Expires = DateTime.Now.AddYears(-1); 
     Response.Cookies.Add(cookie2); 
     foreach (var cookie in Request.Cookies.AllKeys) 
     { 
      Request.Cookies.Remove(cookie); 
     } 
     // Redirect the user to the login page 
     return RedirectToAction("LogOn"); 
    } 
+0

您如何存储身份验证信息?是否有可能为同一用户保存多个密码? – 2012-03-30 02:56:38

+0

存储在SQL表中 - 不 - 我没有为同一用户存储多个密码。另外,如果我选择一个我没有在浏览器中使用过的用户,我不能重复这个行为。 (在IE中更改,然后打开Firefox,只有新的工作)。 – user1166147 2012-03-30 03:02:24

+0

您可能想尝试不删除()所有的cookie。这可能会导致服务器不返回他们的过期日期。 – 2012-03-30 03:29:06

回答