我在管理区域现在想要将值发送到帐户控制器,这是默认区域我如何发送
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);
}
答案 0 :(得分:4)
<强> There isn't an overload for RedirectToAction
that takes 4 parameters 强>
试试这个:
return RedirectToAction(
"ChangePassword",
"Account",
new { area = "", model = mode });
答案 1 :(得分:3)
return RedirectToAction("ChangePassword", "Account",
new { area = "other_area_name", model = mode });
@mattytommo的答案是正确的解决方案,4个参数没有重载方法。我更新了我的答案。