Here is the ajax call:
$.ajax({ url: "/TheControllerName/MyMethod",
type: "GET",
contentType: "application/json", dataType: 'json',
success: function (data) {
alert('something');
},
error: function (httpRequest, textStatus, errorThrown) {
console.log("status=" + textStatus + ",error=" + errorThrown);
}
})//end of ajax call
Here is the method:
public JsonResult MyMethod()
{
//get some list
return Json(theList, JsonRequestBehavior.AllowGet);
}
The method is getting called and the breakpoint comes out of it succesfully but I get this error: 500 (Internal Server Error) status=error,error=Internal Server Error
Set the accept type to json and not the content-type, the reason it works when you enter the url is because this isnt set