User.Identity.IsAuthenticated always false in .net core custom authentication

前端 未结 4 1459
無奈伤痛
無奈伤痛 2020-12-30 04:25

Can anyone please check below code and let me know why I\'m getting always false (User.Identity.IsAuthenticated)??. I\'m getting cookie on my browser properly and able to

4条回答
  •  粉色の甜心
    2020-12-30 04:47

    ClaimsIdentity.IsAuthenticated returns false when ClaimsIdentity.AuthenticationType is null or empty. To avoid that, stop using the parameterless ClaimsIdentity constructor and use the overload accepting an authenticationType parameter:

    var userIdentity = new ClaimsIdentity("Custom");
    

提交回复
热议问题