简体   繁体   中英

POST 500 (Internal Server Error) asp.net mvc

I'm trying to post an object into json server but I got the 500 internal server error. In this code is working fine in localHost but live not working, any this wrong in my code

$.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);
  }
});

Code:

[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();
            }
        }

I would try to look at the network tab in the browser developer tools if you cannot debug the server. Hopefully you can get insight on why the error is being thrown. Select the failed request and look at the response.

Try to make sure the CheckAvailabilty view is added. See answer below:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM