我正在创建一个使用ASP.NET MVC的Web应用程序,该应用程序使用表单验证来验证用户。我正在使用一个名为“Burp”的HTTP代理工具来捕获已验证用户的身份验证cookie。之后,我从应用程序中注销。现在,我正在使用捕获的身份验证cookie向服务器发送请求,并且服务器将该请求视为已验证请求(即使该用户已从我的浏览器注销)。请问有人能告诉我我在注销代码中哪里出错了吗?
以下是我的应用程序注销代码:
以下是Burp工具发送身份验证请求并获得成功响应的屏幕截图:
以下是我的应用程序注销代码:
public virtual ActionResult LogOff()
{
FormsAuthentication.SignOut();
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);
HttpCookie cookie3 = new HttpCookie("__RequestVerificationToken", "");
cookie3.Expires = DateTime.Now.AddYears(-1);
Response.Cookies.Add(cookie3);
HttpCookie cookie4 = new HttpCookie(".ASPXAUTH", "");
cookie4.Expires = DateTime.Now.AddYears(-1);
Response.Cookies.Add(cookie4);
return RedirectToAction(MVC.Account.Login());
}
以下是Burp工具发送身份验证请求并获得成功响应的屏幕截图:
cookie3
和cookie4
又将cookie2
的属性设置为了过期,这是有意为之吗? - Guruprasad J Rao