问题
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