コード例 #1
0
        public ActionResult Register(RegisterModel model)
        {
            if (!ModelState.IsValid)
            {
                if (model == null)
                    model = new RegisterModel();
                model.Init(GetSupportedLocales(), GetSupportedTimeZones(), _membershipService.MinPasswordLength);
                return View(model);
            }

            // Attempt to register the user
            MembershipCreateStatus createStatus = _membershipService.CreateUser(model.Email, model.Password, model.UserName, model.Locale, model.TimeZone);

            if (createStatus == MembershipCreateStatus.Success)
            {
                _formsAuthService.SignIn(model.Email, false /* createPersistentCookie */);
                return RedirectToAction("Index", "Home");
            }

            ModelState.AddModelError("_FORM", ErrorCodeToString(createStatus));

            model.Init(GetSupportedLocales(), GetSupportedTimeZones(), _membershipService.MinPasswordLength);
            // If we got this far, something failed, redisplay form
            return View(model);
        }
コード例 #2
0
 public ActionResult Register()
 {
     RegisterModel model = new RegisterModel();
     model.Init(GetSupportedLocales(), GetSupportedTimeZones(), _membershipService.MinPasswordLength);
     return View(model);
 }