Why do I only have a subset of asp.net membership

2019-07-22 20:27发布

Summary: I am trying to use asp.net membership, roles, and profiles, but am having trouble getting my code to use the tables generated by aspnet_regsql.exe.

What I tried:

  1. Ran aspnet_regsql.exe on my database. This worked and all the tables were created.
  2. Called Membership.CreateUser("tester7","tester7","tester7@hi.com");

This then created the following tables and stored the user in dbo.Memberships instead of dbo.aspnet_Memberships.

  • dbo.Applications
  • dbo.Memberships
  • dbo.Profiles
  • dbo.Roles
  • dbo.Users
  • dbo.UsersInRoles

It completely ignored the tables created by aspnet_regsql.exe.

Why is this happening and what can I do to target to aspnet_* tables?

Edit to include Web.config Membership registration

<membership defaultProvider="ProjectMembershipProvider">
  <providers>
    <add name="ProjectMembershipProvider" type="System.Web.Providers.DefaultMembershipProvider,..." connectionStringName="ProjectSql" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" applicationName="Project" />
  </providers>
</membership>

1条回答
萌系小妹纸
2楼-- · 2019-07-22 20:44

You must add registering section in your config file

System.Web.Providers.DefaultMembershipProvider are on Sql Compact and Azur application

You have section for membership and another for role manager

<membership>

  <providers>

    <add

      name="AspNetSqlMembershipProvider"

      type="System.Web.Security.SqlMembershipProvider, ..."

      connectionStringName="LocalSqlServer"

      enablePasswordRetrieval="false"

      enablePasswordReset="true"

      requiresQuestionAndAnswer="true"

      applicationName="/"

      requiresUniqueEmail="false"

      passwordFormat="Hashed"

      maxInvalidPasswordAttempts="5"

      minRequiredPasswordLength="7"

      minRequiredNonalphanumericCharacters="1"

      passwordAttemptWindow="10"

      passwordStrengthRegularExpression=""

    />

  </providers>

</membership>
查看更多
登录 后发表回答