public ActionResult JsonRegister(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, createPersistentCookie: false);
              return Json(new { success = true });
            }
            else
            {
              ModelState.AddModelError("", ErrorCodeToString(createStatus));
            }
              }

              // If we got this far, something failed
              return Json(new { errors = GetErrorsFromModelState() });
        }
        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, createPersistentCookie: false);
              return RedirectToAction("Index", "Home");
            }
            else
            {
              ModelState.AddModelError("", ErrorCodeToString(createStatus));
            }
              }

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