Posts

Showing posts from December, 2009

ASP.NET MVC 2 breaks Json

Staring at the title of the post, some will say that it actually fixes Json. However, what a developer that hasn´t carefully read the release notes of MVC 2 will discover, is the following. After happily installing the shinny new version, if you try to run a project that was initially built using an older version of MVC, Asp.Net will through an error when attempting to return JSON in response to a GET request.

Microsoft has built this in order to protect you against cross-site attacks. If you feel save either because the data to be posted is not worth stealing or for any other reason, to bypass this, add JsonRequestBehavior.AllowGet to the Json return function.