3

我正在尝试过滤 Kendo UI 网格服务器端过滤器。开发人员工具在查询字符串中显示了这一点

/Home/GetUsmMessage?{"filter":{"logic":"and","filters" [{"field":"MessageId","operator":"eq","value":1}]},"组”:[]} GET 200 应用程序/json

我创建了一个对象结构,以便将结构读取到对象

    public ActionResult GetUsmMessage(FilterContainer filter)
    {
        //Code to read the filter container
        return Json(jsonData, JsonRequestBehavior.AllowGet);
    }

过滤容器的对象结构:

public class FilterContainer
{
    public List<FilterDescription> filters { get; set; }
    public string logic { get; set; }
}
public class FilterDescription
{
    public string @operator { get; set; }
    public string field { get; set; }
    public string value { get; set; }

    public List<FilterDescription> filters { get; set; }
    public string logic { get; set; }
}

当我调试控制器功能时,它仍然给我一个空对象。请帮忙

4

2 回答 2

1

得到了答案...我忘记将请求类型添加为 Http post ....

于 2012-08-12T14:32:31.440 回答
0

对于 WebApi 控制器,您可以使用 [FromUri] 属性和 GET 动词:

    public HttpResponseMessage Get(
[FromUri]IEnumerable<SortParameter> sort, 
[FromUri]FilterContainer filter, 
int take = 10, int skip = 0)
于 2012-09-18T11:34:55.330 回答