我正在使用C#MVC应用程序,我在控制器中有2个操作方法:
[MultipleButton(Name = "action", Argument = "Save")]
public ActionResult SaveBasicInformation(FormCollection collection)
{.....}
[MultipleButton(Name = "action", Argument = "Submit")]
public ActionResult SubmitRequest(FormCollection collection)
{....}
上面的代码在没有ajax请求的情况下工作正常。现在我的问题是如何在$ .ajax(..)中传递“FormCollection”以获取特定的控制器方法。
var input = $(':input');
$.ajax({
url: '@Url.Action("SaveBasicInformation", "Home")',
type: 'POST',
cache: false,
data: input,
success: function (data) {
alert("Success");
},
error: function (result) {
alert("Error");
alert(result.responseText);
}
});
以下是使用上述ajax代码时的错误消息:
The current request for action 'SaveBasicInformatio'' on controller type HomeController'
is ambiguous between the following action methods: System.Web.MVC.Action Result
SubmitRrquest(System.Web.formCollection)....
感谢您的帮助......
答案 0 :(得分:0)
`[MultipleButton]'属性是自定义属性possibly from this SO answer?这可能导致问题,因为它是一个ajax调用。尝试删除属性。