Using MembershipCreateStatus in MVC
Posted
by Jemes
on Stack Overflow
See other posts from Stack Overflow
or by Jemes
Published on 2010-04-15T22:36:02Z
Indexed on
2010/04/16
8:53 UTC
Read the original article
Hit count: 281
asp.net-mvc
|asp.net-membership
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);
}
© Stack Overflow or respective owner