I just upgraded to VS 2012 from VS2010 and have some issues with FormsAuthentication.
I have an old code that creates a custom cookie to store som information in it:
public static int SetAuthCookie<T>(this HttpResponse responseBase, string name, bool rememberMe, T userData) { JavaScriptSerializer serializer = new JavaScriptSerializer(); var cookie = FormsAuthentication.GetAuthCookie(name, rememberMe); var ticket = FormsAuthentication.Decrypt(cookie.Value); var newTicket = new FormsAuthenticationTicket(ticket.Version, ticket.Name, ticket.IssueDate, ticket.Expiration, ticket.IsPersistent, serializer.Serialize(userData), ticket.CookiePath); var encodedTicket = FormsAuthentication.Encrypt(newTicket); cookie.Value = encodedTicket; responseBase.Cookies.Add(cookie); return encodedTicket != null ? encodedTicket.Length : 0; } }
After upgrading to .Net 4.5, HttpContext.Current.Request.IsAuthenticated is always null. I saw that there is a new authentication method in .Net 4.5, but I probably will not use it since I will not be able to update the production environment from .Net 4.0. Is there a way to set authentication when using a personalized cookie?
source share