gan450688265
gan450688265
2021-01-17 11:19

httpContextAccessor.HttpContext.SignInAsync

  • asp.net

public void signIn(string account, string password)
        {
            ClaimsIdentity id = new ClaimsIdentity();
            id.AddClaim(new Claim(ClaimTypes.Sid, account));
            id.AddClaim(new Claim(ClaimTypes.Name, password));
            ClaimsPrincipal cp = new ClaimsPrincipal(id);
            _httpContextAccessor.HttpContext.SignInAsync("GdAdmin", cp);
        }

 

 

  services.AddAuthentication(o =>
            {
                o.DefaultAuthenticateScheme = "GdAdmin";
                o.DefaultChallengeScheme = "GdAdmin";
            }).AddCookie("GdAdmin", o => o.LoginPath = "/Login/Index");
            services.AddAssembly("GdSytem.Services");

 

 httpContextAccessor.HttpContext.SignInAsync 无法将值存入缓存中

 var result = _httpContextAccessor.HttpContext.AuthenticateAsync("GdAdmin").Result;

 

获取的 result 为null

  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

0条回答

为你推荐

换一换