views:

41

answers:

2

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?

+2  A: 

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

return RedirectToAction("OriginalAction");
Martin
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
+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
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