Asp.Net Core 2中AuthenticationResponseGrant的替代方案
在AspNet Core 2中是否有以下代码的替代方案Asp.Net Core 2中AuthenticationResponseGrant的替代方案,asp.net,asp.net-core,asp.net-identity,Asp.net,Asp.net Core,Asp.net Identity,在AspNet Core 2中是否有以下代码的替代方案 var identity = HttpContext.User.Identity as ClaimsIdentity; identity.RemoveClaim(Identity.FindFirst("AnnounceCount")); identity.AddClaim(new Claim("AnnounceCount", "Updated Value")); var authenticationManager = System.Web.
var identity = HttpContext.User.Identity as ClaimsIdentity;
identity.RemoveClaim(Identity.FindFirst("AnnounceCount"));
identity.AddClaim(new Claim("AnnounceCount", "Updated Value"));
var authenticationManager = System.Web.HttpContext.Current.GetOwinContext().Authentication;
authenticationManager.AuthenticationResponseGrant = new AuthenticationResponseGrant(new ClaimsPrincipal(identity), new AuthenticationProperties() { IsPersistent = true });
我想更改cookie中的一些用户主体值,我不打算将这些值持久化到数据库中。在Asp Net Core版本2中是否可以使用类似于上述代码的代码?我研究了OnValidatePrincipal
,IClaimsTransformation
实现,但这两种实现都不符合我的需要。我是不是遗漏了什么
谢谢你有没有弄明白这一点?“我遇到了一个类似的问题。@TodBirdsall很抱歉反应太晚。我还是不知道该怎么做。但是,执行
wait_httpContext.SignInAsync(“AuthenticationSchemeThat You Areusing”,new ClaimsPrincipal(identity))代码>为我工作。