Using MembershipCreateStatus in MVC
- by Jemes
How can I use the MembershipCreateStatus in my controller below to identify errors?
My controller below creates a new user but I would like to catch any errors from CreateStatus and add the error to my modelstate.
[HttpPost]
public ActionResult CreateUser(user UserToCreate)
{
if (ModelState.IsValid)
{
// TODO: If the UserToCreate object is Valid we'll
//Eventually want to save it in a database
Membership.CreateUser(UserToCreate.Username, UserToCreate.Password, UserToCreate.Email);
return Redirect("/");
}
//Invalid - redisplay form with errors
return View(UserToCreate);
}