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 Answers 2

3

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

return RedirectToAction("OriginalAction");
Sign up to request clarification or add additional context in comments.

1 Comment

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"});
2

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.

1 Comment

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.