Bruno Machado - vargero
Bruno Machado - vargero

Reputation: 2730

How to enable JSON calls in my ASP.NET MVC 2 application?

I'm trying to make a dynamic chart using HighCharts, but as it seems to be, is impossible to include ASP tags inside a JavaScript, so I'm trying to use JSon. I followed this tutorual step-by-step, but when I try to load the page, I get the following message:

This request has been blocked because sensitive information could be disclosed to third party web sites when this is used in a GET request. To allow GET requests, set JsonRequestBehavior to AllowGet.

So now I'm wondering if I have to set something in Web.Config or somewhere else.

Could you guys help me?

Upvotes: 3

Views: 1689

Answers (1)

Travis Gockel
Travis Gockel

Reputation: 27673

There is a pretty simple fix. In your request-handling functions, where you would have:

return Json(myStuff);

Replace it with the overload that takes a JsonRequestBehavior:

return Json(myStuff, JsonRequestBehavior.AllowGet);

Upvotes: 6

Related Questions