有没有办法让多个 html 开始表单调用多个 Controller ?
示例:
我在1个 View 上有两个表单A和B,然后表单A调用 Controller C,B调用D,这可以实现吗?如果是这样,我会使用 Ajax 或有什么建议吗?
感谢帮助
最佳答案
表单不需要绑定(bind)到构建其 View 的 Controller 。您可以发布到任何您想要的内容:
@using (Html.BeginForm("SomeAction", "Home"))
{
I'll post to the Home controller.
}
@using (Html.BeginForm("SomeOtherAction", "Security"))
{
I'll post to the Security controller.
}
这只是呈现常规形式,因此:
<form action="/Home/SomeAction">
</form>
<form action="/Security/SomeOtherAction">
</form>
这是 ASP.NET MVC 做对而 WebForms 做不到的众多事情之一。如果您尝试发布到 WebForms 世界中的不同 aspx 页面,则不会那么容易。
关于html - ASP MVC 多个 HTML 开始表单和多个 Controller ?可能的,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19981208/