How to create a ClaimIdentity in asp.net 5

做~自己de王妃 提交于 2019-12-12 20:37:40

问题


In old asp.net identity 2.0, there is a CreateIdentityAsync() method in type Microsoft.AspNet.Identity.UserManager. But now asp.net 5 has removed this method, how can I create a ClaimsIdentity representing the user now? Thanks in advance.

public virtual Task<ClaimsIdentity> CreateIdentityAsync(TUser user, string authenticationType);

回答1:


Is this what you are looking for?

http://aspnet-docs-example.readthedocs.org/en/latest/autoapi/Microsoft/AspNet/Identity/IUserClaimsPrincipalFactory-TUser/

IUserClaimsPrincipalFactory Interface

Provides an abstraction for a factory to create a System.Security.Claims.ClaimsPrincipal from a user.




回答2:


This has been changed to UserManager.CreateAsync and returns an IdentityResult indicating whether or not the new user was successfully created.

If you want to add Claims, you can do this via UserManager.AddClaimAsync.




回答3:


Here you can find how to work with ClaimIdentity example with a sample downloadable project



来源:https://stackoverflow.com/questions/33737757/how-to-create-a-claimidentity-in-asp-net-5

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!