C# 将部分视图模型发布到同一MVC页面

C# 将部分视图模型发布到同一MVC页面,c#,asp.net,asp.net-mvc,asp.net-mvc-4,razor,C#,Asp.net,Asp.net Mvc,Asp.net Mvc 4,Razor,从基本的MVC模板中,我修改了Manage.cshtml以包含一个部分,即\u accountsetingsparial: <section id="accountSettings"> @Html.Partial("_AccountSettingsPartial") </section> @if (ViewBag.HasLocalPassword) { @Html.Partial("_ChangePasswordPartial")

从基本的MVC模板中,我修改了
Manage.cshtml
以包含一个部分,即
\u accountsetingsparial

<section id="accountSettings">            
    @Html.Partial("_AccountSettingsPartial")
</section>
@if (ViewBag.HasLocalPassword)
{
    @Html.Partial("_ChangePasswordPartial")
}
我已尝试将其加载到其他部分:

[HttpPost]
[ValidateAntiForgeryToken]
public async Task<ActionResult> Manage(ManagePublicSettingsViewModel model)

如何使我的
\u accountsetingspartial
页面从用户帐户管理门户发回数据?

您的部分中需要有单独的表单,以便发布到不同的操作。(或者您可以使用JQuery等更改单个表单的操作,但这会更容易。)

然后,您需要对操作进行唯一命名

[HttpPost]
[ValidateAntiForgeryToken]
public async Task<ActionResult> ManagePublicSettings(ManagePublicSettingsViewModel model)

...

[HttpPost]
[ValidateAntiForgeryToken]
public async Task<ActionResult> ManageUser(ManageUserViewModel model)
[HttpPost]
[ValidateAntiForgeryToken]
公共异步任务ManagePublicSettings(ManagePublicSettingsViewModel模型)
...
[HttpPost]
[ValidateAntiForgeryToken]
公共异步任务ManageUser(ManageUserViewModel模型)

看起来您有两个同名的方法,但编译器不知道要调用哪个方法。重命名其中一个。@Serv但是我如何将要发布的模型关联到该视图?
System.Reflection.AmbiguousMatchException: The current request for action 'Manage' on controller type 'AccountController' is ambiguous between the following action methods:
System.Threading.Tasks.Task`1[System.Web.Mvc.ActionResult] Manage(crapplication.Models.ManagePublicSettingsViewModel) on type crapplication.Controllers.AccountController
System.Threading.Tasks.Task`1[System.Web.Mvc.ActionResult] Manage(crapplication.Models.ManageUserViewModel) on type crapplication.Controllers.AccountController
@using (Html.BeginForm("ManagePublicSettings", "Account", FormMethod.Post))

...

@using (Html.BeginForm("ManageUser", "Account", FormMethod.Post))
[HttpPost]
[ValidateAntiForgeryToken]
public async Task<ActionResult> ManagePublicSettings(ManagePublicSettingsViewModel model)

...

[HttpPost]
[ValidateAntiForgeryToken]
public async Task<ActionResult> ManageUser(ManageUserViewModel model)