我在管理方面現在要發送的值來應對控制器,它是在默認區域,我怎麼可以把在其他領域的行動重定向動作與模型帕門
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);
}
+1。我沒有看到我的錯誤,你是對的。 – 2013-03-19 12:25:36
ITs工作,但它重定向到[HttpGet]行動我想重定向到[Httppost]方法 – 2013-03-19 12:27:14
@MoeezAgha沒有問題。你不能重定向到'HttpPost'動作,它必須是'HttpGet'。 – mattytommo 2013-03-19 12:29:59