So I have a HttpPost
only ActionResult
called Edit
. After doing its thing (logic etc), I want it to redirect to a different controller. Lets say the HomeController
. Here it is:
[HttpPost]
public ActionResult Edit(Chair chair, string xml)
{
if (ModelState.IsValid)
{
try
{
_repository.EditChair(chair, xml);
return RedirectToRoute(new { contoller = "Home", action = "index"});
}
catch (Exception ex)
{
//error msg for failed edit in XML file
ModelState.AddModelError("", "Error editing record. " + ex.Message);
}
}
return View(Chair);
}
Ive tryed other things like return RedirectResult()
, RedirectToAction()
, RedirectToRoute("string")
- but it still keeps returning the index view from the controller the Edit
method is in (ChairController
).
Whats the right way to do this??
Typo:
contoller = "Home"
should be
controller = "Home"
or:
return RedirectToAction("index", "home");