RedirectToAction from inside [HttpPost] to [HttpGet] - parameters
asp.net-mvc-3, c#
Solution
Error message is clear...
... if you know that an optional parameter is a parameter with a default value (empty string in your case)
[HttpPost]
public ActionResult Edit(EditViewModel viewModel, string itemId="")
{
// ...
RedirectToAction("Edit", new { id = itemId });
}
and you're done
Problem
Code below: ``` [HttpGet] public ActionResult Edit(string id="") { // ... } [HttpPost] public ActionResult Edit(string itemId="", EditViewModel viewModel) { // ... RedirectToAction("Edit", new { id = itemId }); } ``` returns an error: `"Optional parameters must appear after all required parameters"`. I assume it's trying to redirect to [HttpPost] action. How to redirect to [HttpGet] action? I'm trying to implement Save functionality where it will save the edit and reload the form with new values.