要调用此方法,“Membership.Provider”属性必须是“ExtendedMembershipProvider”的实例

时间:2015-08-18 10:26:24

标签: mysql asp.net-mvc

我正在开发Asp.Net WebAPI项目。我正在使用MySQL会员提供商。在创建帐户时,我得到以下例外:

  

要调用此方法,“Membership.Provider”属性必须是“ExtendedMembershipProvider”的实例

的Web.Config

 <membership defaultProvider="MySQLMembershipProvider">
  <providers>
    <clear/>
    <add name="MySQLMembershipProvider" type="MySql.Web.Security.MySQLMembershipProvider, MySql.Web, Version=6.9.7.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" connectionStringName="DefaultConnectionString" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="true" applicationName="/" requiresUniqueEmail="false" passwordFormat="Clear" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="7" minRequiredNonalphanumericCharacters="1" passwordAttemptWindow="10" passwordStrengthRegularExpression="" />
  </providers>
</membership>

  <profile defaultProvider="MySQLProfileProvider" enabled="true">
    <providers>
      <clear />
      <add type="MySql.Web.Profile.MySQLProfileProvider, MySql.Web, Version=6.8.3, Culture=neutral" name="MySqlProfileProvider" applicationName="/" connectionStringName="DefaultConnectionString" autogenerateschema="true" />
    <remove name="MySQLProfileProvider" />
      <add name="MySQLProfileProvider" type="MySql.Web.Profile.MySQLProfileProvider, MySql.Web, Version=6.9.7.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" connectionStringName="DefaultConnectionString" applicationName="/" /></providers>
  </profile>

  <roleManager enabled="true" defaultProvider="MySQLRoleProvider">
    <providers>
      <clear />
      <add connectionStringName="DefaultConnectionString" applicationName="/" name="MySqlRoleProvider" type="MySql.Web.Security.MySQLRoleProvider, MySql.Web" autogenerateschema="true" />
    <remove name="MySQLRoleProvider" /><add name="MySQLRoleProvider" type="MySql.Web.Security.MySQLRoleProvider, MySql.Web, Version=6.9.7.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" connectionStringName="DefaultConnectionString" applicationName="/" /></providers>
  </roleManager>

1 个答案:

答案 0 :(得分:1)

要使用成员资格提供程序,首先需要在AppStart中初始化(InitializeDatabaseConnection)成员资格提供程序

xcdatamodel
Using MySQL 5 , Simple Membership Provider, ASP.NET MVC4 with Entity Framework 5