I have setup a getJSON call when page loads in my .NET MVC app like this:
$(document).ready(function(){
$.getJSON("/Administrator/GetAllUsers", function (res) {
// getting internal server error here...
});
});
And the action looks like this:
[HttpGet]
[ActionName("GetAllUsers")]
public string GetAllUsers()
{
return new JavaScriptSerializer().Serialize(ctx.zsp_select_allusers().ToList());
}
I'm getting this error:
500 (Internal Server Error)
What am I doing wrong here???
return Json(ctx.zsp_select_allusers(), JsonRequestBehavior.AllowGet);public ActionResult GetAllUsers()orpublic JsonResult GetAllUsers().ToList()(its being serialized, so therefore the collection is being iterated)