我的ClaimsIdentity IsAuthenticated始终为false

时间:2019-10-07 08:52:55

标签: .net angular authentication authorize

我在Web应用程序中登录,但是isAuthenticated变量始终返回false

*

  

https://imgur.com/a/mRWYlBj#YtR6jJf //此代码返回true   https://imgur.com/a/mRWYlBj#Nj332IC //此代码返回false

*


   ClaimsPrincipal icp = Thread.CurrentPrincipal as ClaimsPrincipal;
        ClaimsIdentity claimsIdentity = (ClaimsIdentity)icp.Identity;
        bool isAuthenticated = icp.Identity.IsAuthenticated;

        if (!HttpContext.Current.User.Identity.IsAuthenticated)
        {
            base.HandleUnauthorizedRequest(actionContext);
        }
        else
        {
            actionContext.Response = new System.Net.Http.HttpResponseMessage(System.Net.HttpStatusCode.Forbidden);
        }

0 个答案:

没有答案