![](/img/trans.png)
[英]Unable to post data to ASP.Net Web API Controller using ExtJS
[英]unable to post the data with bool value in asp.net web api
我正在使用 EF 代碼首先使用現有數據庫處理 asp.net mvc webapi。 我有一個班級,
public class User
{
public bool IsAgree{get; set;}
}
我正在使用 MySql 數據庫,我的表看起來像。
--------------
|ID |IsAgree|
--------------
|int |tinyint|
--------------
我有一個像
public HttpReponseMessage PostUser(HttpRequestMessage request,User user)
{
// some code to handle user data..
}
在我看來,我正在嘗試將一些數據發布到操作中,例如,
$(document).ready(function () {
var sendata = {"IsAgree":true};
$.ajax({
url: '/api/account',
type: 'POST',
data: sendata,
dataType: "json",
contentType: "application/json; charset=utf-8",
cache: false,
success: function (data) {
alert(data.status);
},
error: function (xhr) { alert(xhr.status); }
});
});
當我在操作中設置斷點時,它顯示用戶為null
,我收到警報消息為400
即錯誤請求。 我的 json 數據是否適合我的模型? 請指導我。
嘗試以這種方式發送數據:
數據:JSON.stringify({senddata })
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.