我已经能够调用Membership.CreateUser
已在我的数据库中创建必要的成员资格表,但它没有将新创建的用户添加到Users
表和{{1} } - 不确定这意味着什么。
MembershipCreateStatus = InvalidAnswer
配置:
public void Register(Register register)
{
var member = new System.Web.Providers.DefaultMembershipProvider();
object guid = Guid.NewGuid();
MembershipCreateStatus status;
member.CreateUser(register.Username, register.Password, "", "", "", true, guid, out status);
}
答案 0 :(得分:0)
这里的答案是基于我们的讨论。
我认为您已将web.config
中的enablePasswordRetrieval="false"
指定为此
然后此代码将适合您
try
{
object guid = Guid.NewGuid();
MembershipCreateStatus status;
MemberShipUser member = Membership.CreateUser(register.Username, register.Password, "an email address here", null, null, true, guid, out status);
}
catch(MembershipCreateUserException ex)
{
//handle exceptions
}