在以下操作方法Create之间请求不明确

时间:2014-11-14 14:58:06

标签: c# asp.net-mvc-4 knockout.js

我查看了网站上的解决方案。我为[HttpPost]创建了两个方法,为[HttpGet]创建了另一个方法,如图所示,但我仍然收到该错误消息。代码如图所示。但当我向服务器发出一个帖子请求时,我仍然得到错误。

     [HttpGet]
    public ActionResult Create()
    {
        return View();
    }



    [HttpPost]
    public String Create(Customer Customer)
    {
     /// logic here 
      return "Done";
    }

当前的控制器类型'****** Controller'上的“创建”操作请求在以下操作方法之间不明确: System.String在Data.Controllers.UserController类型上创建(Data.Models。***) System.Web.Mvc.ActionResult在Data.Controllers.UserController类型上创建(System.Web.Mvc.FormCollection)我从javascript代码调用该方法,如下所示,当我收到错误消息时。

 $.ajax({
        url: urlPath + '/Create',
        type: 'post',
        dataType: 'json',
        data: ko.toJSON(this),
        contentType: 'application/json',
        success: function (result) {
            window.location.href = urlPath + '/';
        }

1 个答案:

答案 0 :(得分:2)

检查错误消息。这些方法都可以。但是,您使用Create参数FormCollection的另一个Create(System.Web.Mvc.FormCollection)方法:{{1}}。如果你没有那种方法,也许你忘了建立你的项目了?