2009-10-12 18 views
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)如果这是不可能的或任何其他解决方案,去解决它?

在此先感谢您的帮助。

回答

2

使用profiles为此,而不是帐户。关于在MVC中使用配置文件,另请参阅this question

相关问题