Since ASP.NET MVC2, when you try to return a Json result without additional information, you get an error:
This request has been blocked because sensitive information could be disclosed to third party web sites when this is used in a GET request.
You must now set the property JsonRequestBehavior
to the value AllowGet
:
result.JsonRequestBehavior = JsonRequestBehavior.AllowGet;
I read on a post that this prevents hijacking.
I wanted to know if there is an equivalent with Json.Net to prevent this type of attack.
Here is my code to create the Json result:
protected JsonNetResult JsonNet(object data)
{
JsonNetResult result = new JsonNetResult();
result.Data = data;
return result;
}
And if you want to know where I found the JsonNetResult, here is a link.
Thank you very much.