我有我的控制器,它可以发送一个 json 对象并再次接收相同的对象。我的问题是 AjaxSaveFoo 创建了一个 Foo 对象,但我总是得到一个空对象。如何创建反序列化?
/// <summary>
/// Returns a foo
/// </summary>
/// <returns></returns>
public JsonNetResult AjaxLoadFoo()
{
return new JsonNetResult
{
Data = new Foo()
};
}
/// <summary>
/// Saves a foo
/// </summary>
/// <returns></returns>
public JsonNetResult AjaxSaveFoo(Foo foo) //who tries to deserialize this!!, its always empty
{
return new JsonNetResult
{
Data = foo
};
}
我的客户端..
$.ajax({
type: "POST",
url: "AjaxSaveFoo",
data: JSON.stringify(this._FooObj),
success: this.saveSucces,
dataType: "json",
contentType: "application/json; charset=utf-8",
error: this.saveFailure
});
Foo当它被发送下来时..
{
"CustomerNumber": 2,
"CustomerStatus": "1"
}
Foo 提交时(POST)
{"CustomerNumber":2,"CustomerStatus":"1"}