我有一条路线:
routes.MapRoute (name: "apicontroller2",
url: "api/{controller}/{action}/",
defaults: new { controller = "Default2", action = "Index" }
);
和具有两个 post 方法的 Default2Controller:
[HttpPost]
public HttpResponseMessage Post(ttReview review)
{
...
}
[HttpPost]
public HttpResponseMessage PostPro(ttbewertungenpro pro)
{
...
}
webserver/api/default2/PostPro/
当我通过或webserver/api/default2/Post/
ajax post调用这些 API-Methods 时,我得到了错误:
ExceptionMessage=Multiple actions were found that match the request:
System.Net.Http.HttpResponseMessage Post(WT.Models.ttReview) on type WT.Controllers.Default2Controller
System.Net.Http.HttpResponseMessage PostPro(WT.Models.ttbewertungenpro) on type WT.Controllers.Default2Controller
我的ajax调用是:
$.ajax({
url: "../api/default2/Post", // or "../api/default2/PostPro",
type: 'POST',
dataType: "text",
data: review, // or pro
success: function (test) {
},
error: function (test) {
alert("Error");
}
}
我的路线错了还是什么?当我删除一种方法时,另一种方法有效...