Reputation: 1272
I am working on an app using the ASP.NET membership provider. By default, i can use a few fields such as username, password. How to add to the asp.net membership provider so I can add Profile fields such as "firstName", "lastName" in the register section and have it save to the database in aspnet_profile table along with other data.
I am creating a user in the account model as below:
public ActionResult Register(RegisterModel model)
{
if (ModelState.IsValid)
{
// Attempt to register the user
MembershipCreateStatus createStatus;
Membership.CreateUser(model.UserName, model.Password,
model.Email,model.PasswordQuestion,model.PasswordAnswer,
true, null,out createStatus);
if (createStatus == MembershipCreateStatus.Success)
{
FormsAuthentication.SetAuthCookie(model.UserName, false);
return RedirectToAction("Index", "Home");
}
else
{
ModelState.AddModelError("", ErrorCodeToString(createStatus));
}
}
return View(model);
}
Now which function i should use to store profile info into db? Help me !!
Upvotes: 0
Views: 2673
Reputation: 31
Add the fields to the profile section of Web.Config.
<profile>
<properties>
<add name="FirstName" />
<add name="LastName" />
<add name="Address1" />
<add name="Address2" />
<add name="City" />
<add name="State" />
<add name="Zip" />
<add name="Phone" />
<add name="ProfileVersion" type="int" defaultValue="0" />
</properties>
</profile>
For more information please visit: http://msdn.microsoft.com/en-us/magazine/cc163457.aspx
Upvotes: 3