public ActionResult Register(RegisterModel model) { if (ModelState.IsValid) { // Attempt to register the user try { VerificationEmployee ve = (VerificationEmployee)Session["UserProfile"]; WebSecurity.CreateUserAndAccount(model.UserName, model.Password, new { EmployeeId = ve.EmployeeId, EmployeeName = ve.Name, Address = ve.Address, BirthDate = ve.BirthDate, BirthPlace = ve.BirthPlace }); WebSecurity.Login(model.UserName, model.Password); return RedirectToAction("Index", "Home"); } catch (MembershipCreateUserException e) { ModelState.AddModelError("", ErrorCodeToString(e.StatusCode)); } } // If we got this far, something failed, redisplay form return View(model); }
public ActionResult Register(RegisterModel model) { if (ModelState.IsValid) { // Attempt to register the user try { WebSecurity.CreateUserAndAccount(model.UserName, model.Password); WebSecurity.Login(model.UserName, model.Password); return RedirectToAction("Index", "Home"); } catch (MembershipCreateUserException e) { ModelState.AddModelError("", ErrorCodeToString(e.StatusCode)); } } // If we got this far, something failed, redisplay form return View(model); }