错误:无法加载资源:服务器响应状态为500(asp.net中的内部服务器错误

时间:2018-11-25 08:51:22

标签: javascript asp.net ajax

出了什么问题:ajax代码。出错

  

无法加载资源:服务器的状态为500(内部服务器错误)

我真正搜索过的

可以找出问题所在。在第二次尝试而不更改任何内容的情况下,我得到此错误

  

开机自检       http://localhost:51477/Customers/SaveCustomer 500(内部服务器错误)

   $(document).ready(function () {
      $("#btnSave").click(function () {

        var data = JSON.stringify({
            _id: $("#Customerid").val(),
            customertype: $("#CustomerType option:selected").val(),
            pricetype: $("#Pricetype option:selected").val(),
            customername: $("#Customername").val(),
            idnumber: $("#Idnumber").val(),
            contact: $("#Contact").val(),
            location: $("#Location").val(),
            loyaltycard: $("#loyalty").val(),
            creditlimit: $("#credit").val(),
            remainingcredit: $("#credit").val()
        });

        $.ajax({
            type: "POST",
            url: "/Customers/SaveCustomer",
            data: data,
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: function(result) {

                location.reload();
                alert(result);
            },
            error: function (result) {
                alert(result+" Error!");
            }
        });


    });
});

dapper插入代码

      [HttpPost]
      public ActionResult SaveCustomer(newCustomers customers,int _id=0)
      {

         var result = "Error! Customers Required Details Have Not Been Entered!";
          if (_id == 0)
          {

                 DapperOrm.ExcuteToSave("sp_CustomerInsertNew", new 
        DynamicParameters(new
                {
                    //custType = customers.customerType == null ? "credit" : 
        customers.customerType,
                    customertype = customers.customertype == null ? 1 : 
         customers.customertype,
                    pricetype = customers.pricetype == "" ? "retail" : 
         customers.pricetype,
                    customername = customers.customername,
                    idnumber = customers.idnumber,
                    contact = customers.contact,
                    location = customers.location,
                    loyaltycard = customers.loyaltycard,
                    creditlimit = customers.creditlimit == null ? 0 : 
     customers.creditlimit,
                    remainingcredit = customers.creditlimit == null ? 0 : 
     customers.creditlimit
                   }));


          }
       return Json(result, JsonRequestBehavior.AllowGet);

0 个答案:

没有答案