Search code examples
c#asp.net-mvcasp.net-membershipmembership-provider

Custom ASP.NET Universal Provider or SimpleMembership


In an application that has access to a database through a service layer can you create a custom Universal Provider or custom SimpleMembership so that instead of using an EF context that is linked to a database you can overwrite the providers methods to make a service call instead?


Solution

  • Universal Provider and SimpleMembership Provider are just implementations of the abstract base class MembershipProvider. If you wanted to make your own using a service you created you can write your own provider which implements MembershipProvider. You would most likely need to create your own RoleProvider as well as this will be called when you use the [Authorize] attribute on your controllers.

    Further information:

    Implementing a membership provider

    Implementing a role provider

    Once created you can reference your own providers in your web.config and use them the same way you would use the built in providers