POST 500(内部服务器错误)asp.net mvc

时间:2018-06-21 08:37:49

标签: javascript jquery ajax asp.net-mvc

我正在尝试将对象发布到json服务器中,但出现了500个内部服务器错误。在这段代码中,在localHost上工作正常,但无法正常工作,这在我的代码中有任何错误

$.ajax({
  type: 'POST',
  url: '/Booking/CheckAvailability',
  dataType: 'json',
  cache: false,
  data: { 
    LocationID: locationID, 
    VenueID: venueID, 
    FacilityID: facilityID, 
    BookedFromDate: bookedFromDate, 
    BookedToDate: bookedToDate, 
    FromTime: fromtime, 
    ToTime: Ttime 
  },
  traditional: true,
  success: function (data) {
    if (data.success) {
      $("#VenueBooking").show();
    }
    if (data.False) {
      alert("Aleardy Booked");
    }
  },
  error: function (ex) {
    alert('Failed to retrieve Sub Categories : ' + ex);
  }
});

代码:

[HttpPost]
        public ActionResult CheckAvailability(int locationID, int venueID, int facilityID, string bookedFromDate, string bookedToDate, string fromTime, string toTime)
        {

            try
            {
                Get_Location();
                if (ModelState.IsValid)
                {
                    locationInformation check = new locationInformation();
                    bool suc = check.CheckAvailability(bookedFromDate, bookedToDate, fromTime, toTime);
                    if (suc == false)
                    {
                        return Json(new { success = true, message = "Checked successfully" }, JsonRequestBehavior.AllowGet);
                    }
                    else if (suc == true)
                    {
                        return Json(new { False = true, message = "Checked successfully" }, JsonRequestBehavior.AllowGet);
                    }
                }
                return View();
            }
            catch
            {
                return View();
            }
        }

1 个答案:

答案 0 :(得分:0)

如果您无法调试服务器,我将尝试查看浏览器开发人员工具中的“网络”标签。希望您能了解为什么会引发错误。选择失败的请求,然后查看响应。

请尝试确保已添加CheckAvailabilty视图。请参阅下面的答案:

partial view was not found or no view engine supports the searched locations