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

后端 未结 9 1351
清歌不尽
清歌不尽 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 20:53

    Instead of returning a string in your WebMethod use:

    JavaScriptSerializer js = new JavaScriptSerializer();
    Context.Response.Write(js.Serialize(YOUR_STRING_TO_OUTPUT));
    

提交回复
热议问题