AspNet Core 2中是否有以下代码的替代方法?
<div class="container">
<div>Element</div>
<div class="top">Top Element</div>
<div>Element</div>
<div class="bottom">Bottom Element</div>
<div>Element</div>
</div>
我想更改cookie中的一些User Principal值,我不打算在数据库中保留这些值。是否可以在Asp Net 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 });
,OnValidatePrincipal
实现,但这两个都不符合我的需求。我在这里错过了什么吗?
由于