当我提交此网址时:
http://localhost:3333/User/GetAll?_dc=1345288777353&page=1&start=1&limit=25&callback=Ext.data.JsonP.callback2
控制器不会反序列化PagingModel page
。调试器显示page = null
。
public class PagingModel
{
public string start { get { return _start; } set { _start = value; } }
private string _start;
}
public class UserController : Controller
{
[HttpGet]
public JsonResult GetAll(PagingModel page)
{
///////////////////
//page is null.
///////////////////
}
}
答案 0 :(得分:1)
糟糕,重命名您的操作参数:
[HttpGet]
public JsonResult GetAll(PagingModel model)
{
///////////////////
// model is no longer null
///////////////////
}
之所以这样,是因为您的请求中已经有page=1
个查询字符串参数,使得默认模型绑定器变得狂暴,他们正在尝试将值1
反序列化为PagingModel
显然很难发生。