public ActionResult Register(RegisterModel registration) { if (ModelState.IsValid) { // Attempt to register the user try { var user = service.Insert(new User { Email = registration.Email, Login = registration.UserName, }, registration.Password); if (user != null) { return View("RegisterSuccess"); } } catch (Exception exc) { this.ModelState.AddModelError("", exc.Message); } } // If we got this far, something failed, redisplay form ViewBag.PasswordLength = service.MinRequiredPasswordLength; return View(registration); }