asp.net mvc控制器中触发的额外事件

asp.net mvc控制器中触发的额外事件,asp.net,asp.net-mvc,razor,Asp.net,Asp.net Mvc,Razor,在我的ASP.NETMVC应用程序中,我需要向用户提供编辑其配置文件的能力。由于概要文件中有许多字段,我将概要文件分为三个部分。每个部分本身就是一个页面,带有相应的“保存”按钮。My AccountController类具有以下方法: public ActionResult ProfileSection1() { ProfileSection1Model model = ProfileSection1Model.create(); return View(mode

在我的ASP.NETMVC应用程序中,我需要向用户提供编辑其配置文件的能力。由于概要文件中有许多字段,我将概要文件分为三个部分。每个部分本身就是一个页面,带有相应的“保存”按钮。My AccountController类具有以下方法:

  public ActionResult ProfileSection1() {
       ProfileSection1Model model = ProfileSection1Model.create();
       return View(model);
  }

  public ActionResult ProfileSection1(ProfileSection1Model model) {
       ...logic to save the model
       return View(model);
  }
同样,我有ProfileSection2和ProfileSection3的控制器方法和相应的视图

例如,我可以导航到
localhost:xxx/Account/ProfileSection1
。所有页面都按预期工作

现在,我创建了一个新页面EditProfile,并使用引导选项卡控件在不同选项卡下添加了指向每个页面的链接:

<div class="tab-content">
    <div role="tabpanel" class="tab-pane active" id="personal">@Html.Action("ProfileSection1")</div>
    <div role="tabpanel" class="tab-pane" id="address">@Html.Action("ProfileSection2")</div>
    <div role="tabpanel" class="tab-pane" id="public">@Html.Action("ProfileSection3")</div>
</div>

@Html.Action(“ProfileSection1”)
@Html.Action(“ProfileSection2”)
@Html.Action(“ProfileSection3”)
例如,我可以转到第三个选项卡,编辑ProfileSection3中的值,然后单击Save按钮。在控制器上,
ProfileSection3(ProfileSection3Model模型)
按预期调用。到目前为止还不错

然而,在控制器上,
ProfileSection1(ProfileSection1Model模型)
也会被调用,尽管我甚至没有在第一个选项卡上单击Save

我想知道为什么调用了不正确的方法。更重要的是,如果有办法改变这种行为


我曾想过在每个选项卡下使用
iframe
,但如果可能,我希望避免使用iframe。注意。

问题在于子操作调用的模型绑定/操作选择也使用原始请求中的POST参数。我不知道如何修复它。这些方法是否都返回不同的表单?每个表单中的
action
属性的值是多少?看起来您有一个表单和多个提交按钮?所以可能每个控制器都会调用,你能共享生成的视图源吗。每个页面独立地返回一个表单。使用控制器方法上的“创建视图”自动生成每个页面的代码。所以它们都有标准动作属性。