2

How to change in ClaimsPrincipal.Current identity collection the primary one identity ? I saw there is ClaimsPrincipal.PrimaryIdentitySelector, but I am not sure when it is fired and how it have to work.

As I sow I can only add a new one ClaimIndetity to the collection, but I can not set it as primary. If I can not do that then default Account control in MVC does not see provided user name .

Thank you, Rastko

4

1 回答 1

0

如果您有多个身份,并且假设其中只有一个具有名称声明。你可以这样做。

public class MyPrincipal : ClaimsPrincipal
{
    public MyPrincipal() 
    {
        PrimaryIdentitySelector = (ids) => ids.FirstOrDefault(id => id.Name == ClaimTypes.Name);
    }
}

}

于 2014-02-26T21:26:21.097 回答