Skip to content

Instantly share code, notes, and snippets.

@pauldambra
Created January 12, 2012 13:03
Show Gist options
  • Save pauldambra/1600391 to your computer and use it in GitHub Desktop.
Save pauldambra/1600391 to your computer and use it in GitHub Desktop.
Edited Register Model
[HttpPost]
public ActionResult Register(RegisterModel model)
{
if (ModelState.IsValid)
{
// Attempt to register the user
MembershipCreateStatus createStatus;
Membership.CreateUser(model.UserName, model.Password, model.Email, null, null, true, null, out createStatus);
if (createStatus == MembershipCreateStatus.Success)
{
FormsAuthentication.SetAuthCookie(model.UserName, false);
//Changes here
//Create loads or creates a profile based on searching for username
var userProfile = ProfileBase.Create(model.UserName) as CustomProfile;
userProfile.Address = model.Address;
userProfile.Save();
//End of changes
return RedirectToAction("Index", "Home");
}
else
{
ModelState.AddModelError("", ErrorCodeToString(createStatus));
}
}
// If we got this far, something failed, redisplay form
return View(model);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment