code formating

Wednesday, December 2, 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.

No comments:

Post a Comment

Programatically walk a CATIA tree in .NET

One of the most basic tasks when automating anything in CATIA, it's usually to walk the whole tree and apply some changes to objects in ...