Json allowget error Json allowget error jquery jquery

Json allowget error


Answer for your question was in the stack trace. "JsonRequestBehavior to AllowGet"

So use it in your Controller as:

return Json(data, JsonRequestBehavior.AllowGet)


You should read http://haacked.com/archive/2009/06/24/json-hijacking.aspx/ before bypassing these security controls.

If you only expose your JSON data in response to a Http POST, then you are not vulnerable to this attack.

You can simply annotate your JSON action with [HttpPost] and in the client do something like

$.post('/blag/JSON', function (data) {       //do something with my json data object here});


It seems that you call sometime the controller action per HTTP GET. To be able to return JSON results you should use code like

return Json(data, JsonRequestBehavior.AllowGet);