Jtable 与服务器通信时发生错误。 - post 500 错误

Jtable An error occured while communicating to the server. - post 500 error

当我添加一条新记录时出现上述错误,下面是我的代码,我在 google 上进行了一些搜索,但我无处可去,如果有人能指出我,我将不胜感激正确的方向。

 $('#dataContent').jtable({
            title: 'Data List',
            paging: true,
            pageSize: 5,
            actions: {
                listAction:'/Test.aspx/GetAllCars',
                createAction: 'Test.aspx/CreateCar'

            },
            fields: {
                ID: {
                    key: true,
                    create: false,
                    edit: false,
                    list: false
                },
                Make: {
                    title: 'Make',
                    width: '20%'
                },
                Model: {
                    title: 'Model',
                    width: '20%'
                },
                Engine: {
                    title: 'Engine',
                    width: '20%'
                },
                Year: {
                    title: 'Year',
                    width: '20%'
                }
            }

        });

        $('#dataContent').jtable('load');

    });


    [WebMethod(EnableSession = true)]
    public static Object CreateCar(Car c) {
        try {
            bool addresult = new CarRepo().CreateCar(c);
            return new { Result = "OK" };

        }
        catch (Exception ex) {
            return new { Result = "ERROR", Message = ex.Message };
        }

    }


 public bool CreateCar(Car c) {

        using(var context = new DAL.DbAccess.DataContext()) {
            try {
              var Irepo = new DAL.Repository.MainRepository<Car>(context);
              Irepo.Insert(c);
              return true;
            } catch(Exception ex) {
                ex.ToString();
                return false;
            }

        }
    }

POST http://localhost:51598/Test.aspx/GetAllCars

200 行 4毫秒 jquery-....min.js(第 3 行) POSThttp://localhost:51598/Test.aspx/CreateCar

500 内部服务器错误 7毫秒 jquery-....min.js(第 3 行) HeadersPostResponseJSON

{"Message":"Invalid web service call, missing value for parameter: \u0027c\u0027.","StackTrace":" at System.Web.Script.Services.WebServiceMethodData.CallMethod(Object target, IDictionary2 parameters)\r\n at System.Web.Script.Services.WebServiceMethodData.CallMethodFromRawParams(Object target, IDictionary2 parameters)\r\n at System.Web.Script.Services.RestHandler.InvokeMethod(HttpContext 上下文、WebServiceMethodData 方法数据、IDictionary`2 rawParams)\r\n 在 System.Web.Script.Services.RestHandler.ExecuteWebServiceCall(HttpContext 上下文、WebServiceMethodData 方法数据)","ExceptionType":"System.InvalidOperationException"}

500 是服务器意外情况代码。这看起来不像是 JavaScript 问题。您正在使用 .Net aspx 页面。您可能需要确保 IIS 服务器已正确设置和运行。

http://www.w3.org/Protocols/HTTP/HTRESP.html

找到应该是的问题

     [WebMethod(EnableSession = true)]
     public static Object CreateCar(Car **record**) {
         try {
            bool addresult = new CarRepo().CreateCar(record);
            return new { Result = "OK" };

        }
        catch (Exception ex) {
            return new { Result = "ERROR", Message = ex.Message };
        }

    }