ASPXAUTH cookie始终为null

时间:2015-05-26 18:55:37

标签: .net asp.net-mvc

由于某种原因,ASPXAUTH始终为null,即使它确实存在于FireBug Cookies选项卡下。

  if (Request.Cookies[".ASPXAUTH"] != null)
    {
        HttpCookie myCookie = new HttpCookie(".ASPXAUTH");
    }
是什么给了什么?

1 个答案:

答案 0 :(得分:1)

要获取应用程序的cookie,请尝试以下方法:

HttpCookie appCookie = context.HttpContext.Request.Cookies[FormsAuthentication.FormsCookieName];

解密它,你可以使用:

FormsAuthenticationTicket ticket = FormsAuthentication.Decrypt(appCookie.Value);

//您可以使用'机票'来获取信息。宾语。

 string cookikePath = ticket.CookiePath;
 DateTime expiration = ticket.Expiration;
 bool expired = ticket.Expired;
 bool isPersistent = ticket.IsPersistent;
 DateTime issueDate = ticket.IssueDate;
 string name = ticket.Name;
 string userData = ticket.UserData;
 string version = ticket.Version;