I am on Admin area now want to send the values to Account Controller which is in default area how i can send
ChangePasswordModel mode = new ChangePasswordModel();
mode.ConfirmPassword = password;
mode.NewPassword = password;
mode.OldPassword = user.Password;
return RedirectToAction("ChangePassword", "Account",new { area = '/' } , new {model = mode});
this is my other action in Account Controller where i want to redirect my code
[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);
}
There isn't an overload for RedirectToAction
that takes 4 parameters.
Try this:
return RedirectToAction(
"ChangePassword",
"Account",
new { area = "", model = mode });
return RedirectToAction("ChangePassword", "Account",
new { area = "other_area_name", model = mode });
@mattytommo ' s answer is the right solution, there is no overload method for 4 parameters. I updated my answer.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With