1
我想我做的是添加一些字段給aspnet_Users,例如RealName和avatar,但是,我想在創建用戶時在這些字段中插入值。如何自定義AccountController/Register用戶操作以將數據添加到自定義字段?
由於用戶是通過管理員CP創建的,因此我已將操作的名稱更改爲創建,而不是註冊。
我認爲這是我需要改變的行動,以獲得我想實現的目標。
<AcceptVerbs(HttpVerbs.Post)> _
Function Create(ByVal userName As String, ByVal email As String, ByVal password As String, ByVal confirmPassword As String) As ActionResult
ViewData("Title") = "Register"
ViewData("PasswordLength") = MembershipService.MinPasswordLength
If ValidateRegistration(userName, email, password, confirmPassword) Then
' Attempt to register the user
Dim createStatus As MembershipCreateStatus = MembershipService.CreateUser(userName, password, email)
If createStatus = MembershipCreateStatus.Success Then
FormsAuth.SignIn(userName, False)
Return RedirectToAction("Index", "Home")
Else
ModelState.AddModelError("_FORM", ErrorCodeToString(createStatus))
End If
End If
Return View()
End Function
不過,我也不太清楚如何去增加新的領域,以插入和我都相信自己就不能那麼容易,因爲改變MembershipService.CreateUser(userName, password, email)
線,其中包括我的新字段的值。
有人可以指出我正確的方向,1)如果這是可能的,如何去做或2)如果這是不可能的或任何其他解決方案,去解決它?
在此先感謝您的幫助。