2

Is there anyway to make multiple html begin forms call multiple controllers?

Example:

I have two forms A and B on 1 view, then form A call controller C and B calls D, is this possible to implement this? If so, would I use Ajax or any suggestion?

Thanks for help

1
  • Yes, it is possible. You dont need ajax for it. Commented Nov 14, 2013 at 15:15

1 Answer 1

3

A form doesn't need to be tied to the controller which built its view. You can post to whatever you want:

@using (Html.BeginForm("SomeAction", "Home"))
{
    I'll post to the Home controller.
}

@using (Html.BeginForm("SomeOtherAction", "Security"))
{
    I'll post to the Security controller.
}

This just renders regular forms, so:

<form action="/Home/SomeAction">
</form>

<form action="/Security/SomeOtherAction">
</form>

This is one of the many many things that ASP.NET MVC got right and WebForms did not. If you tried to post to a different aspx page in the WebForms world, it would not be so easy.

Sign up to request clarification or add additional context in comments.

Comments

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.