MVC Web API,错误:无法绑定多个参数 [英] MVC Web API, Error: Can't bind multiple parameters
本文介绍了MVC Web API,错误:无法绑定多个参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
传递参数时出现错误
无法绑定多个参数"
"Can't bind multiple parameters"
这是我的代码
[HttpPost]
public IHttpActionResult GenerateToken([FromBody]string userName, [FromBody]string password)
{
//...
}
Ajax:
$.ajax({
cache: false,
url: 'http://localhost:14980/api/token/GenerateToken',
type: 'POST',
contentType: "application/json; charset=utf-8",
data: { userName: "userName",password:"password" },
success: function (response) {
},
error: function (jqXhr, textStatus, errorThrown) {
console.log(jqXhr.responseText);
alert(textStatus + ": " + errorThrown + ": " + jqXhr.responseText + " " + jqXhr.status);
},
complete: function (jqXhr) {
},
})
推荐答案
查看全文