asmx web service returning xml instead of json in .net 4.0
Posted
by Baldy
on Stack Overflow
See other posts from Stack Overflow
or by Baldy
Published on 2010-05-01T12:45:07Z
Indexed on
2010/05/01
12:47 UTC
Read the original article
Hit count: 216
i have just upgraded a test copy of my site to asp.net 4.0 and have noticed a strange issue that only arises when i upload the site to my server.
the site has an asmx web service that returns json, yet when i run the site on my server it returns xml. it as been working fine in asp.net 3.5 for over a year.
the webMethod is decorated with the correct attributes...
[WebMethod][ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public List<LocationRecentChange> RecentChanges()
and on my local machine it returns json.
yet on the server (Windows 2008 64bit) it returns xml.
you can inspect the response on the test site here...
using firebug console you will see a 200 OK response and a bunch of XML, and on my local machine the data returned is the JSON i expect.
Here is the javascript that calls the service..
function loadRecentData() {
$.ajax({
type: "POST",
url: "service/spots.asmx/RecentChanges",
data: "{}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: loadRecentUpdates,
failure: function(msg) {
//alert(msg);
}
});
}
Any suggestions welcome, this has got me stumped!
© Stack Overflow or respective owner