Question

I'm creating a ASP.NET MVC 4 application that uses Database First Entity Framework for database access. I have my own membership tables and I implemented my own Membership provider and Role provider. The problem is that i don't know how to use them. Is there a way to override WebSecurity class or change its methods so it uses my Membership provider? Or should I use Membership and Role provider directly without the WebSecurity facade?

Was it helpful?

Solution

The WebSecurity helper class is designed for use with the ExtendedMembershipProvider class (on which SimpleMembershipProvider amongst others are based). If you based your provider and your site is configured to use an ExtendedMembership based provider, the recommended approach is to use WebSecurity (although it exposes only a subset of what the underlying provider interface is capable of.

If your provider is based on the original .NET MembershipProvider and your site is configured accordingly, you will deal directly with the provider: typically the Membership and Role classes.

This article gives a useful overview of the relationship between the different providers and the ways they are intended to be used: http://weblogs.asp.net/jgalloway/archive/2012/08/29/simplemembership-membership-providers-universal-providers-and-the-new-asp-net-4-5-web-forms-and-asp-net-mvc-4-templates.aspx

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top