【问题标题】:How to update a claim in ASP.NET Identity 3.0?如何更新 ASP.NET Identity 3.0 中的声明?
【发布时间】:2016-10-22 22:15:03
【问题描述】:

我在一个 asp.net 项目中工作,我需要更新身份声明的值。

我读到了:

How to update a claim in ASP.NET Identity?

我想在 Identity 3.0 中做类似的事情。

【问题讨论】:

    标签: asp.net asp.net-identity claims-based-identity


    【解决方案1】:

    试试这样的?

    var identity = new ClaimsIdentity(User.Identity);
    identity.RemoveClaim(identity.FindFirst("name"));
    identity.AddClaim(new Claim("name", "Jon"));
    
    var authenticationManager = HttpContext.GetOwinContext().Authentication;
    authenticationManager.AuthenticationResponseGrant = new AuthenticationResponseGrant(
        new ClaimsPrincipal(identity),
        new AuthenticationProperties
        {
            IsPersistent = true
        });
    

    【讨论】:

      猜你喜欢
      • 2014-08-26
      • 1970-01-01
      • 1970-01-01
      • 2016-02-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-03-11
      • 2018-05-17
      相关资源
      最近更新 更多