I have 3 forms on my View. Each of these all post back to a different action. When the action is complete, I call my original Action that led the user to the page originally, but MVC is looking for a view of the postback Action. How can I get MVC to post to an action of a different name of the current view, while still having it reload the same page?
views:
41answers:
2
+2
A:
Return this when you are done with your post pack Action:
return RedirectToAction("OriginalAction");
Martin
2010-10-19 18:51:58
Liked the way this one worked. I had to pass in the parameter it needed as well, so just put RedirectToAction("OriginalAction", new {param = "blah"});
DavidAndroidDev
2010-10-20 17:04:51
+1
A:
How I would solve the problem:
In your view, for each form:
<% using(Html.BeginForm<ControllerController>(c => c.Action1(param))
{
// Form Stuff
} %>
In your action:
[HttpPost]
public ActionResult Action1(type param)
{
// Do your work;
return this.RedirectToAction(c => c.OrigionalAction(param));
}
The strongly typed Html.BeginForm is from MVCFutures (Microsoft.Web.Mvc) The strongly typed RedirectToAction is from MvcContrib.
ARM
2010-10-19 18:55:43
totally off topic, but thanx, used mvc a while ago, and in the new project i couldn't figure out how i managed the strongly typed forms and actions
Dusty Roberts
2010-10-21 09:28:56