问题
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:
- Ran aspnet_regsql.exe on my database. This worked and all the tables were created.
- 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:
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>
来源:https://stackoverflow.com/questions/12203495/why-do-i-only-have-a-subset-of-asp-net-membership-tables