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

October 22, 2012

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>

 

tags:
posted in Blog by Magnus Johansson

Follow comments via the RSS Feed | Leave a comment | Trackback URL

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

  1. Atlas wrote:

    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. Adam wrote:

    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.NET\ASP.NET Web Pages\v2.0\Assemblies

    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. Lena wrote:

    Thanks for helpful material! You saved me from hours of work!

  4. Thiago Silva wrote:

    @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.

  5. Sid Ben wrote:

    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.

  6. Stephen McMahon wrote:

    Just wanted to say thanks for offering exactly the solution that I needed.

  7. tom wrote:

    Thanks!

  8. To call this method, the "Membership.Provider" property must be an instance of "ExtendedMembershipProvider" | BlogoSfera wrote:

    [...] http://insomniacgeek.com/to-call-this-method-the-membership-provider-property-must-be-an-instance-of… [...]

  9. Alan wrote:

    Man! U definately rocks!!

    Solve my problems and my frustation.. hehehe

  10. Tim wrote:

    This is exactly what I needed. The Jon Galloway article had me so confused.

  11. Gustavo wrote:

    Thank you very much!!!

Leave Your Comment

 
Powered by Wordpress and MySQL. Theme by Shlomi Noach, openark.org