To call this method, the “Membership.Provider” property must be an instance of “ExtendedMembershipProvider”.

Membership Provider property must be an instance of ExtendedMembershipProvider

Have you just created an ASP.NET MVC 4 internet project, decided to use the universal providers to utilize SQL Azure? So you have installed the NuGet package Microsoft ASP.NET Universal Providers and now your project bombs with:

To call this method, the “Membership.Provider” property must be an instance of “ExtendedMembershipProvider”.

You search for a solution, find Jon Galloway article SimpleMembership, Membership Providers, Universal Providers and the new ASP.NET 4.5 Web Forms and ASP.NET MVC 4 templates , where he states: “If you want to use the new AccountController, you’ll either need to use the SimpleMembershipProvider or another valid ExtendedMembershipProvider. This is pretty straightforward.”

Well, he fails to describe what you’ll need to do if you want continue to use the AccountController. Fear not, here’s what you’ll have do to.

Edit your web.config and replace:

<profile defaultProvider=DefaultProfileProvider>
<providers>
  <add name=DefaultProfileProvider” type=System.Web.Providers.DefaultProfileProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
connectionStringName=DefaultConnection
applicationName=/ />
  </providers>
</profile>
<membership defaultProvider=DefaultMembershipProvider>
  <providers>
    <add name=DefaultMembershipProvider
type=System.Web.Providers.DefaultMembershipProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35 connectionStringName=DefaultConnection enablePasswordRetrieval=false” enablePasswordReset=true” requiresQuestionAndAnswer=false
requiresUniqueEmail=false” maxInvalidPasswordAttempts=5
minRequiredPasswordLength=6” minRequiredNonalphanumericCharacters=0
passwordAttemptWindow=10
applicationName=/ />
  </providers>
</membership>
<roleManager defaultProvider=DefaultRoleProvider>
  <providers>
    <add name=DefaultRoleProvider type=System.Web.Providers.DefaultRoleProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35 connectionStringName=DefaultConnection applicationName=/ />
  </providers>
</roleManager>

With:

<profile defaultProvider=SimpleProfileProvider>
  <providers>
    <add name=SimpleProfileProvider type=WebMatrix.WebData.SimpleMembershipProvider, WebMatrix.WebData
        connectionStringName=DefaultConnection applicationName=/ />
</providers>
</profile>
<membership defaultProvider=SimpleMembershipProvider>
  <providers>
      <add name=SimpleMembershipProvider” type=WebMatrix.WebData.SimpleMembershipProvider, WebMatrix.WebData />
  </providers>
</membership>
<roleManager defaultProvider=SimpleRoleProvider>
  <providers>
    <add name=SimpleRoleProvider type=WebMatrix.WebData.SimpleRoleProvider, WebMatrix.WebData/>
  </providers>
</roleManager>

 

17 thoughts to “To call this method, the “Membership.Provider” property must be an instance of “ExtendedMembershipProvider”.”

  1. Very usefull ! When I first read the article written by Jon Galloway, I was lost and you gave me all I needed. Thank you !

  2. Thanks! My situation was slightly different – I have built an ASP.net mvc web api app that I want to share my membership tables with – no where could I find any information on how to configure it, until I found your post, so thanks heaps!

    One other step I had to make was to copy the web matrix dlls into my project from this folder:

    C:Program Files (x86)Microsoft ASP.NETASP.NET Web Pagesv2.0Assemblies

    Then it all worked. Now I have a nice, simple shared security model for my web app as well as my web api rest service. I wonder why this isn’t included out of the box.. seems like a perfectly normal thing to do, with a very obscure solution!!

    Cheers!

  3. @Adam Instead of copying DLLs around, you should use Nuget packages. THe Web Matrix references are installed as packages in the MVC4 template in VS2012, and you can see them.

    If you need to use them elsewhere, install the Web Matrix Web Data package.

  4. Thanks, this solved for me too.

    There are a lot of unreliable tutorials out there, looks like MVC changed a lot of core features from 3 to 4.

  5. Ah thank you! thank you! thank you! thank you!
    I was doing so much hair pulling on this I was about to subscribe to hair club for men. :-))

  6. Hi, thanks for this useful post. I have been trying to use SimpleMembershipProvider and changing minRequiredNonalphanumericCharacters. It seems it is impossible. isn’t it?

  7. I tried your solution but I get the following error when I run the application:

    provider must implement the class ‘system.web.security.roleprovider’

    Please help.

  8. With the changes in web.config and having the universal providers installed, can we connect to SQL Azure?

    Thanks

  9. Thanks alot , this very useful, i had scratched the net without find a working solution after getting lost with Jon Galloway’s article .

Leave a Reply

Your email address will not be published. Required fields are marked *