0
我大概只是累了,没有看到有什么不对这个所以也许你人可以给我一个想法。使用自定义FormsAuthentication问题的FormsAuthenticationTicket
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,
FormsAuthentication.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");
在我的控制器行动 我有一个部分与@ Html.ActionLink(“注销”,“注销”,“帐户”) 在为退出的行动,我只是有 FormsAuthentication.SignOut
那么现在的问题是,SignOut不会删除AuthTicket,我仍然看到的cookie和用户不能注销.. :)酷吧?
LOL ...去图右。我可以做到这一点,但我太OCD不能找出这一个。 – CrazyCoderz 2011-05-19 16:02:40
@Assistant〜我在这块岩石上打了我的头。它坚持了一大堆的cookie,所以它重新创建了cookie的价值。类似的东西。如果您找到更多信息,请告诉我。 – jcolebrand 2011-05-19 16:05:46
这似乎解决了这个问题。在我的web.config文件中,我在认证部分设置了loginUrl =“〜/ Account /”。我如果我们没有使用这样做读什么FormsAuthentication.SignOut确实有点.. http://msdn.microsoft.com/en-us/library/system.web.security.formsauthentication.signout.aspx – CrazyCoderz 2011-05-19 16:27:42