ResponseFormat.Json returns xml [duplicate]

I realise this question is old but just in case someone else is looking at this answer in the future ….

I have found (according to this http://encosia.com/asmx-and-json-common-mistakes-and-misconceptions/ and this http://weblogs.asp.net/scottgu/archive/2007/04/04/json-hijacking-and-how-asp-net-ajax-1-0-mitigates-these-attacks.aspx) that if you wish to consume JSON from an .ASMX it’s necessary to :

  • set the content type to ‘application/json’ and
  • set the method to ‘POST’

Up above Yisman says he doesn’t want to restrict his service to POST requests but (according to those two references) it does seem that if you wish to use .ASMX and receive JSON that’s what you’re going to have to do.

Leave a Comment