1

I think what I'm after doing is adding a couple of fields to aspnet_Users such as RealName and avatar for example, however, I want to insert values into these fields on user creation.

I have changed the name of the action to Create as opposed to register as users are created via an Admin CP.

I have assumed that this is the Action I need to alter in order to obtain what I am trying to achieve.

<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

However, I'm not too sure how to go about adding new fields to the insert and I have convinced myself it can't be as easy as changing the MembershipService.CreateUser(userName, password, email) line to include the values of my new fields.

Can someone point me in the right direction as to 1) if this is possible and how to go about it or 2) if this isn't possible or any other solutions as to go about it?

Thanks in advance for any help.

LiamGu
  • 5,317
  • 12
  • 49
  • 68

1 Answers1

2

Use profiles for this, not accounts. See also this question, regarding use of profiles in MVC.

Community
  • 1
  • 1
Craig Stuntz
  • 125,891
  • 12
  • 252
  • 273