小编Tom*_*Tom的帖子

MVC Web API,错误:无法绑定多个参数

传递参数时出错,

"无法绑定多个参数"

这是我的代码

[HttpPost]
public IHttpActionResult GenerateToken([FromBody]string userName, [FromBody]string password)
{
    //...
}
Run Code Online (Sandbox Code Playgroud)

阿贾克斯:

$.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) {

    },
})
Run Code Online (Sandbox Code Playgroud)

c# ajax asp.net-mvc jquery asp.net-web-api

13
推荐指数
1
解决办法
1万
查看次数

标签 统计

ajax ×1

asp.net-mvc ×1

asp.net-web-api ×1

c# ×1

jquery ×1