When I am doing AJAX request to controller, Action Method could not find the View which I am trying to return and throwing the exception as shown at end of the question.
Following is the AJAX method calling the Action Method:
$.ajax({
url: "/Courses/AddTime",
data: { DayName: DayValue, StartTimeValue:
starttimeval,EndTimeValue: EndtimeVal },
dataType: "json",
type: "POST",
error: function () {
alert(" An error occurred.");
},
success: function (data) {
window.location.href = '/Courses/listbatch/?BtchTimingid=' +
data.ID + "&InsertRetId=" + data.secndid;
}
});
Following is Action Method and it is called properly from AJAX request but while returning View it is throwing exception.
public ActionResult listbatch(string Search_name, int? page, int?
BtchTimingid = 0, int InsertRetId=0)
{
/// There Have some code which is working perfect
if (Request.IsAjaxRequest())
return PartialView("_BatchTimingList", model.pageCoursesList);
else
return View(model);
}
The view 'listbatch' or its master was not found or no view engine supports the searched locations. The following locations were searched:
~/Views/Courses/listbatch.aspx ~/Views/Courses/listbatch.ascx ~/Views/Shared/listbatch.aspx ~/Views/Shared/listbatch.ascx ~/Views/Courses/listbatch.cshtml ~/Views/Courses/listbatch.vbhtml ~/Views/Shared/listbatch.cshtml ~/Views/Shared/listbatch.vbhtml