Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/asp.net-core/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net core 如何手动分配用户_Asp.net Core_.net Core_Asp.net Core Mvc - Fatal编程技术网

Asp.net core 如何手动分配用户

Asp.net core 如何手动分配用户,asp.net-core,.net-core,asp.net-core-mvc,Asp.net Core,.net Core,Asp.net Core Mvc,我有所有的索赔,我还检查了令牌是否有效。如何使用IsAuthenticated=true和声明主体登录此新用户 var tokenHandler = new JwtSecurityTokenHandler(); var validationParameters = new TokenValidationParameters() { ValidateIssuerSigningKey = true

我有所有的索赔,我还检查了令牌是否有效。如何使用
IsAuthenticated=true
和声明主体登录此新用户

            var tokenHandler = new JwtSecurityTokenHandler();
            var validationParameters = new TokenValidationParameters()
            {
                ValidateIssuerSigningKey = true,
                IssuerSigningKey = new SymmetricSecurityKey(Encoding.ASCII.GetBytes(conf.GetSection("JWTKey").Value)),
                ValidateAudience = false,
                ValidateIssuer = false
            }
            ;

            SecurityToken validatedToken;
            IPrincipal pr= tokenHandler.ValidateToken(token, validationParameters, out validatedToken);

            var claims = tokenHandler.ReadJwtToken(token).Claims;
            var claimspr = new ClaimsPrincipal(new ClaimsIdentity(cliams,"JWTAuth"));

当您使用.net内核时。您可以使用
HttpContext.SignInAsync
并将
ClaimsPrincipal
作为参数传递。请参见请参见
AuthenticationManager
没有
signin
方法您的AuthenticationManager是这样实现的吗?私有IAAuthenticationManager AuthenticationManager{get{return HttpContext.GetOwinContext().Authentication;}}}噢,我使用的是类“AuthenticationManager”,而不是接口。还有别的办法吗?”IAAuthenticationManager对我大喊大叫,说它与我的应用程序不兼容。尝试安装旧版本也不起作用。