Ane*_*eeq 5 asp.net asp.net-identity asp.net-core
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.HttpContext.Current.GetOwinContext().Authentication;
authenticationManager.AuthenticationResponseGrant = new AuthenticationResponseGrant(new ClaimsPrincipal(identity), new AuthenticationProperties() { IsPersistent = true });
Run Code Online (Sandbox Code Playgroud)
我想更改Cookie中的一些User Principal值,但我不打算将其保留在数据库中。在Asp Net Core版本2中是否可以使用上述代码?我看着OnValidatePrincipal,IClaimsTransformation实现,但两者的那些不适合我的需要。我在这里想念什么吗?
谢谢
| 归档时间: |
|
| 查看次数: |
384 次 |
| 最近记录: |