【发布时间】:2012-11-22 16:44:39
【问题描述】:
我正在使用现有数据库首先使用 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 数据是否适合我的模型?请指导我。
【问题讨论】:
标签: asp.net-mvc jquery asp.net-web-api