ASP.NET JSON web service always return the JSON response wrapped in XML

后端 未结 9 1326
清歌不尽
清歌不尽 2020-12-05 20:17

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]         


        
相关标签:
9条回答
  • 2020-12-05 21:07

    Use like this not return string type.Just write

    public void Metod()
        {
            json = jss.Serialize(Data);
            Context.Response.Write(json);
        }
    
    0 讨论(0)
  • 2020-12-05 21:08

    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 :)

    0 讨论(0)
  • 2020-12-05 21:11

    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.

    0 讨论(0)
提交回复
热议问题