I saw a similar question but it did not resolve my issue. I have a JSON web service in an ASMX file;
The code for the web method
[WebMethod]
Use like this not return string type.Just write
public void Metod()
{
json = jss.Serialize(Data);
Context.Response.Write(json);
}
We have made another page that calls the service server side and writes the response (in our case an .aspx). We cleaned up all the HTML code, doctype head body, and made the server side code to call the service and response.write it.
(in aspx case just leave the page directive at the top)
this way you can get a clean string.
By the way if this is exposing our application to any security threats or major performance hits, I'd really appreciate the comments. Just too busy to ask it here or search on it :)
Try Jayrock for .NET, it's a neat handler for .NET JSON RPC. It'll do exactly what you need. There's a step by step how-to for ASP .NET JSON RPC here.