ASP.net MVC – Multiple Forms on View, each calling a different action, but need to show the same view again – Education Career Blog

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?

,

Return this when you are done with your post pack Action:

return RedirectToAction("OriginalAction");

,

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.

Leave a Comment