Tuesday, April 7, 2015

Adding Claims support to your ASP.NET Web Application

If you are using the new ASP.NET Identity Framework in your ASP.NET Web Application, it is relatively easy to implement Claims in your application since the ApplicationUser and ApplicationUserManager classes already provide support for Claims.

However, what if you are using an older application that does not leverage ASP.NET Identity and you still want to use Claims in your ASP.NET Web Application (ASP.NET Web Forms or ASP.NET MVC)?

Well, fortunately, with the release of ASP.NET v. 4.5, Microsoft has made this process extremely easy!

If you look at the documentation for the FormsIdentity class on MSDN, you can see that it derives from ClaimsIdentity: https://msdn.microsoft.com/en-us/library/system.web.security.formsidentity%28v=vs.110%29.aspx

In fact, nearly every Identity class in .NET v. 4.5 now derives from ClaimsIdentity including GenericIdentity, WindowsIdentity and BasicIdentity!

In the past, developers would extend the IIdentity interface and add their own properties and methods to their derived class.  However, now you can either directly use one of the Identity classes such as FormsIdentity or derive directly from ClaimsIdentity and extend it to add support for Claims or any additional functionality you want to add to your application!

That is all that is needed to get up and running with Claims in your ASP.NET Web Application!


No comments:

Post a Comment