6

我在管理区域现在想将值发送到默认区域中的帐户控制器我如何发送

ChangePasswordModel mode = new ChangePasswordModel();
                mode.ConfirmPassword = password;
                mode.NewPassword = password;
                mode.OldPassword = user.Password;
                return RedirectToAction("ChangePassword", "Account",new { area = '/' } , new {model = mode});

这是我在帐户控制器中的其他操作,我想在其中重定向我的代码

[Authorize]
        [HttpPost]
        public ActionResult ChangePassword(ChangePasswordModel model)
        {
            if (ModelState.IsValid)
            {

                // ChangePassword will throw an exception rather
                // than return false in certain failure scenarios.
                bool changePasswordSucceeded;
                try
                {
                    MembershipUser currentUser = Membership.GetUser(User.Identity.Name, true /* userIsOnline */);
                    changePasswordSucceeded = currentUser.ChangePassword(model.OldPassword, model.NewPassword);
                }
                catch (Exception)
                {
                    changePasswordSucceeded = false;
                }

                if (changePasswordSucceeded)
                {
                    return RedirectToAction("ChangePasswordSuccess");
                }
                else
                {
                    ModelState.AddModelError("", "The current password is incorrect or the new password is invalid.");
                }
            }

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

2 回答 2

5

RedirectToAction不存在需要 4 个参数的重载

试试这个:

return RedirectToAction(
    "ChangePassword",
    "Account",
     new { area = "", model = mode });
于 2013-03-19T12:20:33.193 回答
3
return RedirectToAction("ChangePassword", "Account",
    new { area = "other_area_name", model = mode });

@mattytommo 的答案是正确的解决方案,4 个参数没有重载方法。我更新了我的答案。

于 2013-03-19T12:07:21.353 回答