C# AngularJS SmartTable和ASP.NET映射错误

C# AngularJS SmartTable和ASP.NET映射错误,c#,asp.net,asp.net-mvc,C#,Asp.net,Asp.net Mvc,我尝试从SmartTable实现当前表状态的asp.net映射 我使用ASP.NETMVC5 我的angularjs调用如下所示: usersService.getUsers({ start: start, number: number, tableState: tableState } ).then(function(result) { }

我尝试从SmartTable实现当前表状态的asp.net映射

我使用ASP.NETMVC5

我的angularjs调用如下所示:

 usersService.getUsers({
                start: start,
                number: number,
                tableState: tableState
            }
        ).then(function(result) {

        });
   public JsonResult GetUsers(SmartTableRequestModel request)
        {
            return GetJsonResult(new
            {

            });
        }
我的查询字符串参数如下所示:

number:10
start:0
tableState:{"sort":{"predicate":"location","reverse":false},"search":{"predicateObject":{"location":"gfdgd","service":"gfdgd","company":"gd","fullname":"john"}},"pagination":{"start":0,"number":10}}
当然,我尝试在asp.net中映射查询信息。我的控制器操作如下所示:

 usersService.getUsers({
                start: start,
                number: number,
                tableState: tableState
            }
        ).then(function(result) {

        });
   public JsonResult GetUsers(SmartTableRequestModel request)
        {
            return GetJsonResult(new
            {

            });
        }
我尝试绑定的模型如下:

 public class SmartTableRequestModel
    {
        public SmartTableQueryModel TableState { get; set; }

        public int Number { get; set; } // number is well-binded

        public int Start { get; set; } // the start is well-binded too
    }

 public class SmartTableQueryModel
    {
        [JsonProperty("sort")]
        public SmartTableSortModel Sort { get; set; }

        [JsonProperty("search")]
        public SmartTableSearchModel Search { get; set; }

        [JsonProperty("pagination")]
        public SmartTablePaginationModel Pagination { get; set; }
    }

 public class SmartTableSortModel
    {
        [JsonProperty("predicate")]
        public string Predicate { get; set; }

        [JsonProperty("reverse")]
        public bool Reverse { get; set; }

    }
等等

但是我没有在表状态模型中得到任何映射。SmartTableRequestModel对象的TableState属性始终为空

感谢您的以下帮助,
Razvan

尝试发送请求数据,如下所示

{"request" :{"TableState": {"sort":{"predicate":"location","reverse":false},"search":{"predicateObject":{"location":"gfdgd","service":"gfdgd","company":"gd","fullname":"john"}},"pagination":{"start":0,"number":10}}},"Number":10,"Start":1}

问题是我的getUsers是一个httpget方法,不能将模型传递给httpget方法

所以我改变了我的资源以匹配一个httppost调用

    {
        getUsers: { url: ci.domainPub + '/Management/GetUsers', method: 'POST', action: 'getUsers'},
    },
在控制器中,操作将是:

[HttpPost]
public JsonResult GetUsers(SmartTableRequestModel request)
        {
            return GetJsonResult(new
            {

            });
        }

通过这种机制,您可以发布smartTable插件的表状态,而无需在服务器端进行任何处理和筛选/排序。

我假设您使用的是asp.net MVC。你能发布更多的细节吗,比如你使用的是什么版本的MVC?我更新了我的问题。对不起。我使用ASP.NETMVC5。你试过使用类型转换器或模型绑定器吗?看,这当然行不通。装订不是那样的。你试过了还是猜到了?我试过了,但我确信它不会起作用。问题是,我的getUsers是一个httpget方法,您不能将模型传递给httpget方法并期望它映射。是否有机会将其转换为http post?是的,我改变了这一点,它的工作方式必须如此。谢谢你的支持。