后退按钮显示密码,用户名。即使Cookie已过期?

时间:2016-03-27 06:01:45

标签: asp.net-mvc session-cookies

我正在编写自定义登录 - 在注销时清除cookie

  public ActionResult Logout()
    {
        Session.Remove("Username");
        Session.Clear();
        if (Request.Cookies["Username"] != null)
        {
            HttpCookie usercookie = new HttpCookie("Username");
            usercookie.Expires =DateTime.Now.AddDays(-1);
            Response.Cookies.Add(usercookie);
            Response.Cookies.Set(usercookie);

        }
        if (Request.Cookies["Password"] != null)
        {
            HttpCookie usercookie = new HttpCookie("Password");
            usercookie.Expires = DateTime.Now.AddDays(-1);
            Response.Cookies.Add(usercookie);
            Response.Cookies.Set(usercookie);

        }


       ViewBag.Error = "Logged out !!clear cookie";

       return RedirectToAction("Account","Home");
    }

注销工作正常,但是在浏览器后退按钮上我得到了用户名密码,即使我在注销时清除了cookie。

0 个答案:

没有答案