0

我有以下代码:

var httpCookie = context.HttpContext.Request.Cookies[".ASPXAUTH"];

这适用于 Firefox。[".ASPXAUTH"] 已列出并找到。但是在 Chrome 和 IE9 中它丢失了,因此 httpCookie 为空。

为什么会这样,请问我该如何解决?

提前谢谢了。

4

1 回答 1

3

要获取应用程序身份验证的 cookie,您可以尝试以下操作:

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

要解密它,您可以使用:

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

// you can access all properties using the 'ticket' object. 
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;
于 2013-03-06T17:00:35.197 回答