使用POST查询MVC控制器ActionResult的字符串参数



我有以下查询字符串参数方法是POST使用anularjs作为

var req = {
           method: 'POST',
          url: "/UserGrid",
           params: {
                        rows : 15,
                        page: 1,
                        sidx : "ID",
                        sord: "DESC",
                        _search: true,
                        filters: {"groupOp":"AND","rules":[{"field":"username","op":"cn","data":"suz"}]}
                    }, 
                };
$http(req).success(function(data, status, headers, config){
     console.log(data)
 });
_search:true
filters:{"groupOp":"AND","rules":[{"field":"username","op":"cn","data":"suz"}]}
page:1
rows:3
sidx:ID
sord:desc

我有以下方法

 [HttpPost]
    public ActionResult UserGrid(bool _search, GridFilterHelper filters, int page, int rows, string sidx, string sord)
    {
         GridFilterHelper mFilters = filters;
         return Json(mFilters);
    }
上面代码中的

过滤器null。谁能帮我如何通过过滤器这个动作方法。

这里是grifilterHelper类
public class GridFilterHelper
    {
        public string groupOp { get; set; }
        public List<Rules> rules { get; set; }
    }
    public class Rules
    {
        public string field { get; set; }
        public string op { get; set; }
        public string data { get; set; }
    }

查询字符串参数过滤器为字符串而不是对象。我将string。

改为Json

最新更新