What is the difference between System.IdentityModel & Microsoft.IdentityModel which one should I use?

左心房为你撑大大i 提交于 2020-01-02 09:55:25

问题


I just starting out trying to write a federated claims provider I'm using the http://claimsid.codeplex.com/ examples as my template. So I start up VS2010 to begin my own project and the first thing I notice is that there is a System.IdentityModel as well as Microsoft.IdentityModel. This usually happens when stuff gets added to the .Net framework becoming 'mainstream'.

Is this the case here?

Which one should I use?


回答1:


When using Claims Based authentication/authorization, then you will need to use Microsoft.IdentityModel as that is part of the Windows Identity Framework (WIF).

The System.IdentityModel claim is part of the WCF stack. It was used for Claims before WIF. From what I understand Microsoft.IdentityModel is built on top of System.IdentityModel.

WIF has a dependency on System.IdentityModel. Depending on what you are doing you might need a reference to both.

This is an example, taken from the Claim type (that happens to be in both assemblies):

namespace Microsoft.IdentityModel.Claims
{
    public class Claim
    {
        public Claim(string claimType, string value);
        public Claim(System.IdentityModel.Claims.Claim claim, string issuer);
        ...
    }
}

If you have the choice of using System.IdentityModel and Microsoft.IdentityModel, always use Microsoft.IdentityModel.



来源:https://stackoverflow.com/questions/7883144/what-is-the-difference-between-system-identitymodel-microsoft-identitymodel-wh

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