【问题标题】:POST 500 (Internal Server Error) asp.net mvcPOST 500(内部服务器错误)asp.net mvc
【发布时间】:2018-06-21 08:37:49
【问题描述】:

我正在尝试将对象发布到 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();
            }
        }

【问题讨论】:

  • @RoryMcCrossan 更新
  • 你没有日志?
  • 您需要单步执行您的 c# 代码以查看导致内部错误的原因
  • @Pete 正在制作中。
  • 恐怕,如果日志不能帮助你,我们怎么能?

标签: javascript jquery ajax asp.net-mvc


【解决方案1】:

如果您无法调试服务器,我会尝试查看浏览器开发人员工具中的网络选项卡。希望您可以深入了解引发错误的原因。选择失败的请求并查看响应。

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

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

【讨论】:

    猜你喜欢
    • 2020-12-11
    • 1970-01-01
    • 2019-05-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-10-14
    • 2018-10-10
    • 2011-03-01
    相关资源
    最近更新 更多