这是一个 Web 表单应用程序项目 (WAP)。我正在以编程方式创建具有自定义配置文件属性的用户,并且可以看到用户数据保留在 Users 表中,但不在 aspnet_membership 或 Memberships 表中。使用自定义注册表单创建新用户后,登录失败。任何人都可以建议故障排除清单吗?
MembershipCreateStatus status = MembershipCreateStatus.Success;
MembershipUser newUser
= Membership.CreateUser(userNameTxt.Text.Trim(), passwordTxt.Text,
emailTxt.Text, questionTxt.Text, answerTxt.Text, true, out status);
Roles.AddUserToRole(userNameTxt.Text.Trim(), "Member");
// Gather and save Profile info
CustomProfile profile = CustomProfile.GetProfile(userNameTxt.Text.Trim());
profile.Personal.Email = emailTxt.Text.Trim();
profile.Personal.FirstName = firstNameTxt.Text.Trim();
profile.Personal.LastName = lastNameTxt.Text.Trim();
profile.Save();
错误消息:您的登录尝试不成功。请再试一次。
发生了什么: CreateUser 返回 null
<providers>
<remove name="DefaultMembershipProvider"/>
<add
name="DefaultMembershipProvider"
type="System.Web.Providers.DefaultMembershipProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
connectionStringName="LocalSqlServer"
enablePasswordRetrieval="false"
enablePasswordReset="true"
requiresQuestionAndAnswer="true"
requiresUniqueEmail="false"
minRequiredPasswordLength="6"
minRequiredNonalphanumericCharacters="0"
passwordAttemptWindow="1000"
passwordFormat="Hashed"
applicationName="/" />
</providers>
<remove name="LocalSqlServer" />
<add name="LocalSqlServer"
connectionString="Initial Catalog=MYDB;Data Source=WIN2K8;Integrated Security=SSPI;"
providerName="System.Data.SqlClient" />
<remove name="MYDBConn" />
<add name="MYDBConn" connectionString="Initial Catalog=MYDB;Data Source=WIN2K8;Integrated Security=SSPI;"
providerName="System.Data.SqlClient" />