关于MVC接收Ajax调用无法访问的问题

例如:下面代码有两个int类型的参数,如果Ajax调用时没有在data属性中为其赋值,AJAX会出500异常。

public JsonResult GetList(int pageIndex, int pageSize)
        {
            int total = 0;
            List<ModelEmployeeList> list = BllEmployee.GetList(out total, 1, 10);
            return new JsonResult()
            {
                Data = new ModelCommonJsonResult() { flag = 1, data = new ModelCommonSfDataGridResult() { rows = list, total = total } },
                JsonRequestBehavior = JsonRequestBehavior.AllowGet
            };
        }

尽量避免使用int类型,可以使用int?或是用类来接受一组数据。

原文地址:https://www.cnblogs.com/weiweithe/p/4428229.html