2015-05-26 88 views
1

由於某些原因,ASPXAUTH始終爲空,即使它存在於FireBug Cookie選項卡下。ASPXAUTH cookie始終爲空

if (Request.Cookies[".ASPXAUTH"] != null) 
    { 
     HttpCookie myCookie = new HttpCookie(".ASPXAUTH"); 
    } 

什麼給?

+0

此代碼在請求的管道中位於何處?含義,在控制器中,控制器屬性等 – Tommy

回答

1

爲了讓您的應用程序的餅乾,嘗試這樣的事情:

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;