FormsAuthentication issue with Custom FormsAuthenticationTicket
I am probably just tired and not seeing what is wrong with this so maybe you folks can give me an idea.
public class AuthTicket : IAuthTicket
{
#region IAuthTicket Members
public string CreateAuthenticationTicket(string userName, bool persistent, string userData)
{
var formsAuthenticationTicket = new FormsAuthenticationTicket(1, userName, DateTime.Now,
DateTime.Now.AddDays(5), persistent, userData,
FormsA开发者_如何学Cuthentication.FormsCookiePath);
var encryptedTicket = FormsAuthentication.Encrypt(formsAuthenticationTicket);
return encryptedTicket;
}
#endregion
}
// This is injeted in the ctor
string authTicket = _authTicket.CreateAuthenticationTicket(userId.ToString(), true,
registerOpenIdUserViewModel.DisplayName);
Response.Cookies.Add(new HttpCookie(FormsAuthentication.FormsCookieName,authTicket));
return RedirectToAction("Index", "Home");
In my controller Action I have a partial with @Html.ActionLink("Log Off", "LogOff", "Account") In the Action for LogOff I simply have FormsAuthentication.SignOut
Well here is the problem, SignOut does not delete the AuthTicket, I still see the cookie and the user cannot logoff.. :) Cool eh?
I had this same problem. I just manually forced the cookies to be deleted in my code.
Roles.DeleteCookie( );
精彩评论