FormsAuthentication behält das UserData-Feld nach Postback in .NET 3.5 nicht b
Ich habe ein @ erstelFormsAuthenticationTicket
von Grund auf neu, aber festgestellt, dass beim späteren Abrufen derUserData
kommt nicht zurück. Hier ist der verwendete Code:
FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(
1,
user.UserId,
DateTime.Now,
DateTime.MaxValue,
false,
user.UserType);
HttpCookie cookie = new HttpCookie(
FormsAuthentication.FormsCookieName,
FormsAuthentication.Encrypt(ticket));
Response.Cookies.Add(cookie);
Allerdings, wenn dies auf dem nächsten @ zurücklesRequest
, Ich habe festgestellt, dass dasUserData
Feld ist jetzt leer:
string encryptedCookie = Request.Cookies[ FormsAuthentication.FormsCookieName ].Value;
FormsAuthenticationticket ticket = FormsAuthentication.Decrypt(encryptedCookie);
Assert.IsTrue( ticket.UserData.Length == 0 ); //TRUE!
Irgendwelche Ideen