使用 POST 向 MVC 控制器 ActionResult 查询字符串参数
Query String Parameters to MVC Controller ActionResult using POST
我有以下查询字符串参数方法是 POST 使用 anularjs as
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);
}
上面代码中的filters是null。有人可以帮助我如何将 filters 传递给此操作方法。
这里是 grifilterHelper class
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
我有以下查询字符串参数方法是 POST 使用 anularjs as
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);
}
上面代码中的filters是null。有人可以帮助我如何将 filters 传递给此操作方法。
这里是 grifilterHelper class
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