Willy Van den Driessche
Willy Van den Driessche

Reputation: 1759

What is the difference between microsoft.identityModel and system.identityModel in .NET 4.5

I'm probably not the first to ask but which one should we use now ? As I understand it, it started with a very small System.IdentityModel for WCF. Then came the Microsoft.IdentityModel classes which added a whole lot more. This is the situation as in http://social.technet.microsoft.com/wiki/contents/articles/1898.aspx#v3q10

But now in 4.5, I see that System.IdentityModel has almost all classes from Microsoft.IdentityModel (although there seems to have been some refactoring and the configuration in web.config is slightly different).
Now Microsoft pre-releases a JSON Web Token Handler as a nuget, which depends on Microsoft.IdentityModel AND System.IdentityModel. (JWTSecurityTokenHandler resides in Microsoft.IdentityModel.Tokens.JWT, derives from System.IdentityModel.Tokens.SecurityTokenHandler).

This is getting quite confusing. Does anybody know which one I should use ?

Upvotes: 13

Views: 6248

Answers (2)

thatskj
thatskj

Reputation: 121

The WIF classes, which were collected under the Microsoft.IdentityModel namespaces in WIF 3.5, are now distributed among the following namespaces: System.Security.Claims, System.ServiceModel.Security, and the System.IdentityModel namespaces in WIF 4.5. In addition some WIF 3.5 namespaces were consolidated or dropped entirely in WIF 4.5.

Reference: https://learn.microsoft.com/en-us/dotnet/framework/security/namespace-mapping-between-wif-3-5-and-wif-4-5

Upvotes: 0

Lars Kemmann
Lars Kemmann

Reputation: 5674

The WIF 1.0 release, which is what you get when you download 'Windows Identity Foundation' from Microsoft, targeted .NET 3.5 (and was compatible with .NET 4.0). Since it was an out-of-band release, all types had to live in non-core namespaces (Microsoft.IdentityModel, etc.) and non-core assemblies.

The current WIF 4.5 release (they jumped in the version numbering if I've understood correctly) has been integrated directly into the core .NET 4.5 Framework. The most extreme example, the IClaimsPrincipal interface has been replaced by a ClaimsPrincipal base class from which all the .NET IPrincipal implementations now derive - this is directly in mscorlib.dll. Hence the System.IdentityModel, etc., namespaces.

The pre-released JWT Handler (nuget) is, of course, an out-of-band release. I wouldn't be at all surprised if it makes it into the core .NET vNext (assuming the JWT standard is finalized by then), but until then the framework naming guidelines require that JWTSecurityTokenHandler etc. reside in Microsoft.IdentityModel.

I can understand your confusion; I'm helped by the fact that I can start from scratch on my project with only .NET 4.5 to worry about - for now. :)

Upvotes: 11

Related Questions