本文介绍了RemoveClaimAsync身份2.2的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有问题与Identity 2.0。我试图更新用户索赔。因此,这里是我的code。

I have problem with Identity 2.0 . I'm trying to update claim on a user. So here is my code.

            var UserID = User.Identity.GetUserId();
            var claims = await UserManager.GetClaimsAsync(UserID);

            var displayName = claims.FirstOrDefault(i => i.Type == "DisplayName");
            var isPublic = claims.FirstOrDefault(i => i.Type == "IsPublic");

            if (displayName != null)
                await UserManager.RemoveClaimAsync(UserID, displayName);
            if (isPublic != null)
                await UserManager.RemoveClaimAsync(UserID, isPublic);

            await UserManager.AddClaimAsync(UserID, nClaim("DisplayName", model.DisplayName));
            await UserManager.AddClaimAsync(UserID, nClaim("IsPublic", model.IsPublic.ToString()));

这是我得到的。有没有人有线索?

http://prntscr.com/6azxr5 this is what I get. Does anyone have a clue ?

感谢。

推荐答案

这是由已经被固定在ASP.Net身份版2.1.1知道是不是BUG引起的

可悲的是版本2.1.1还没有上市,在nuget.org但在此期间,你可以从这里下载:
一旦下载到您的NuGet配置在Visual Studio和添加在您下载的软件包作为一个新的源文件夹。
希望它能帮助

This is caused by a know bug which has already been fixed in ASP.Net identity version 2.1.1https://aspnetidentity.codeplex.com/workitem/2509Sadly version 2.1.1 is still not available at nuget.org but in the meantime you can download it from here: https://www.myget.org/gallery/aspnetwebstacknightlyOnce downloaded go to your nuget config in visual studio and add the folder where you downloaded the packages as a new source.Hope it helps

这篇关于RemoveClaimAsync身份2.2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-29 04:42