I need to retrieve JSON or HTML from my MVC controller by an Ajax call. The question is why that below doesn't work with a GET request ?
$.ajax({
url: url,
type: "POST", //It works but doesn't work with GET
success: function (data) {
...
}
});
public ActionResult Index()
{
if (User.Identity.IsAuthenticated)
{
...
return View(selectedUser);
}
return Json(new { Error = Messages.AUTHENTICATIONEXPIRED });
}
With HTTP GET it get nothing instead the Json Object. The Action method is executed successfully. Is there a technical reason that I don't know? is there another way to make it work without making a POST call? Thanks