使用模型作为parmenter将操作重定向到其他区域中的操作

Moe*_*gha 6 c# asp.net-mvc asp.net-mvc-3

我在管理区域现在想要将值发送到帐户控制器,这是我可以发送的默认区域

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

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

[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);
        }
Run Code Online (Sandbox Code Playgroud)

mat*_*mmo 5

没有过载,RedirectToAction它需要4个参数

尝试这个:

return RedirectToAction(
    "ChangePassword",
    "Account",
     new { area = "", model = mode });
Run Code Online (Sandbox Code Playgroud)