Ejemplo n.º 1
0
        public ActionResult Edit()
        {
            MembershipUser user =  Membership.GetUser();
            RegisterModel reg = new RegisterModel { UserName = user.UserName, Email = user.Email };

            return View(reg);
        }
Ejemplo n.º 2
0
        public ActionResult Edit(RegisterModel model)
        {
            // very minimal implementation!
            MembershipUser user =  Membership.GetUser();
            user.Email = model.Email;
            Membership.UpdateUser(user);

            return RedirectToAction("Index", "Home");
        }
Ejemplo n.º 3
0
        public ActionResult Register(RegisterModel model)
        {
            if (ModelState.IsValid)
            {
                // Attempt to register the user
                MembershipCreateStatus createStatus;
                Membership.CreateUser(model.UserName, model.Password, model.Email, null, null, true, null, out createStatus);

                if (createStatus == MembershipCreateStatus.Success)
                {
                    FormsAuthentication.SetAuthCookie(model.UserName, false /* createPersistentCookie */);
                    return RedirectToAction("Index", "Home");
                }
                else
                {
                    ModelState.AddModelError("", ErrorCodeToString(createStatus));
                }
            }

            // If we got this far, something failed, redisplay form
            return View(model);
        }