4

This is my code.

protected UserDataModel GetUserDataFromAuthenticationCookie()
{
    HttpContext.Response.Cookies.Append("authCookie", Request.Cookies[GetCookieKey()]);
    if (HttpContext.Request.Cookies["authCookie"] != null)
    {
        FormsAuthenticationTicket authTicket =
            FormsAuthentication.Decrypt(HttpContext.Request.Cookies["authCookie"]);
        return JsonConvert.DeserializeObject<UserDataModel>(authTicket.UserData);
    }

    return null;
}

I am trying to decrypt cookie data using FormsAuthentication in asp.net core. But it raise build errors for FormsAuthentication. How to implement the deccrypt cookie data in asp.net core

Shaun Luttin
  • 133,272
  • 81
  • 405
  • 467
  • 1
    Take a look at [FormsAuthentication](https://github.com/synercoder/FormsAuthentication) project. – Mark G Jul 17 '18 at 16:31
  • Did anyone find a nice solution here? It's a pity when we want to migrate the project to asp.net core. This will make a huge change for our work based on Form Authentication logic.Why the asp.net core team give up these methods? – Bes Ley Jul 20 '19 at 05:49
  • Anyone reading this can follow this answer: https://stackoverflow.com/questions/65072011/aspnetcore-alternative-for-system-web-security-formsauthenticationticket – Damien Doumer Dec 06 '22 at 14:38

0 Answers0