我无法回答您的其他问题,但这是我使用扩展用户注册以包含更多日期的代码(使用配置文件表,而不是配置文件提供者):
'
' POST: /Account/Register
<HttpPost()> _
Public Function Register(ByVal model As RegisterModel) As ActionResult
If ModelState.IsValid Then
' Attempt to register the user
Dim createStatus As MembershipCreateStatus
Dim MembershipUser = Membership.CreateUser(model.UserName, model.Password, model.Email, Nothing, Nothing, True, Nothing, createStatus)
If createStatus = MembershipCreateStatus.Success Then
Dim providerKeyObject = MembershipUser.ProviderUserKey
Dim providerKeyGuid = MembershipUser.ProviderUserKey
' update profile entity
Dim db As UserProfileDbContext = New UserProfileDbContext
Dim profile As New UserProfile
profile.UserId = providerKeyGuid
profile.IsCompanyOwner = True
profile.CompanyId = model.Company
profile.BlogId = model.Blog
profile.IsCompanyOwner = model.IsCompanyOwner
profile.IsBlogOwner = model.IsBlogOwner
db.UserProfiles.Add(profile)
db.SaveChanges()
FormsAuthentication.SetAuthCookie(model.UserName, False)
' send email
' TODO: fix error on send
Call New EmailController().VerificationEmail(model).Deliver()
Return RedirectToAction("Index", "Home")
Else
ModelState.AddModelError("", ErrorCodeToString(createStatus))
End If
End If
' If we got this far, something failed, redisplay form
Return View(model)
End Function