我创建了一个用户如下:
MembershipCreateStatus status = MembershipCreateStatus.InvalidPassword;
MembershipUser newUser = Membership.CreateUser(userNameTxt.Text.Trim(),
passwordTxt.Text, emailTxt.Text, "N//A", "N//A", 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.Personal.Street = streetTxt.Text.Trim();
profile.Personal.City = cityTxt.Text.Trim();
profile.Personal.State = stateDDL.SelectedValue;
profile.Personal.Zip = zipTxt.Text.Trim();
profile.Save();
我在 DB Profile 表中看到了数据,但在 Users 表中没有看到 - 这是设计使然吗?使用 PasswordRecovery 控件时,它似乎无法识别以这种方式创建的用户。有人可以解释以这种方式创建配置文件时使用哪些表以及如何重置密码?
更新:
测试我的 PasswordRecovery 控件时,用户名为空:
MembershipUser user = Membership.GetUser(User.Identity.Name);
if (Page.IsPostBack)
{
Response.Write(user.UserName);
}
<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"
applicationName="/" >