Search code examples
c#membership-provider

C# membership multiple providers createuser error


I declared 2 Membership Providers:

<membership defaultProvider="AspNetSqlMembershipProvider">
      <providers>
        <clear/>
        <add connectionStringName="ConnectionString1" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" passwordFormat="Hashed" minRequiredNonalphanumericCharacters="2" minRequiredPasswordLength="8" maxInvalidPasswordAttempts="5" passwordAttemptWindow="30" applicationName="/" name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider, System.Web,Version=2.0.0.0, Culture=neutral, PublicKeyToken=xzxzxz"/>
        <add connectionStringName="ConnectionString2" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" passwordFormat="Hashed" minRequiredNonalphanumericCharacters="2" minRequiredPasswordLength="8" maxInvalidPasswordAttempts="5" passwordAttemptWindow="30" applicationName="/" name="AspNetSqlMembershipProviderProduction" type="System.Web.Security.SqlMembershipProvider, System.Web,Version=2.0.0.0, Culture=neutral, PublicKeyToken=xxxx"/>
      </providers>
    </membership>

But when I am calling CreateUser using one of the providers:

var membershipProviderProduction = Membership.Providers["AspNetSqlMembershipProviderProduction"];

MembershipUser newUser = membershipProviderProduction.CreateUser(username, password, email, question, answer, isAproved, out cs);

I get this error:

Error 65 No overload for method 'CreateUser' takes 7 arguments


Solution

  • Well, As much as I know It has 8 parameters Check below

    MembershipUser CreateUser(string username, string password, string email, string passwordQuestion, string passwordAnswer, bool isApproved, object providerUserKey, out MembershipCreateStatus status);
    

    You are missing 'providerUserKey' infact