当传入多个参数时,WebApi
将导致异常"Can't bind multiple parameter to the request's content."
。对以下代码有任何解决方案
public class A1
{
public int id {get;set;}
public string name {get;set;}
}
public class A2
{
public int id2 {get;set;}
public string name2 {get;set;}
}
[Route("Save")]
[HttpPost]
public string Save([FromBody]A1 Emp, [FromBody]List<A2> EmpMarks)
{
}
Run Code Online (Sandbox Code Playgroud)
JS文件
$http({
method: "post",
url: "/api/Employee/Save",
data: JSON.stringify({
Emp: $scope.Emp,
EmpMarks: $scope.EmpMarks
})
}).then(function (response) {
}, function () {
alert("Error Occur");
})
Run Code Online (Sandbox Code Playgroud) 使用 WebApi angularjs 项目并尝试将函数删除为`
[HttpDelete]
public String DeleteCountry(string cntryId)
{
if (cntryId != null)
{
return repoCountry.DeleteCountry(Convert.ToInt32(cntryId));
}
else
{
return "0";
}
}
Run Code Online (Sandbox Code Playgroud)
js函数是
$http({
method: "delete",
url: '/api/Country/DeleteCountry/',
dataType: "json",
data: { cntryId: cntryId }
}).then(function (response) {});
Run Code Online (Sandbox Code Playgroud)
在这里我得到了例外
{"Message":"The requested resource does not support http method 'DELETE'."}
Run Code Online (Sandbox Code Playgroud)
插入、更新和获取功能正常工作。给一个解决方案以及为什么它只发生在删除