5
傳遞參數,當我得到的錯誤,MVC的Web API,錯誤:無法綁定多個參數
"Can't bind multiple parameters"
這裏是我的代碼
[HttpPost]
public IHttpActionResult GenerateToken([FromBody]string userName, [FromBody]string password)
{
//...
}
阿賈克斯:
$.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) {
},
})
可能的複製( https://stackoverflow.com/questions/14407458/webapi-multiple-put-post-parameters) –
親愛的保羅。 我剛剛檢查提到的問題,這不是重複的,因爲這個問題是不同於我目前的問題。謝謝 – Tom
您使用的是Web API 1還是2? –