ASP.NET WebService is Wrapping my JSON response with XML tags

前端 未结 6 1094
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-03 11:49

I\'m not sure where I\'m going wrong of what I\'m missing.

I\'m building an ASP.NET 2.0 (on the .Net 3.5 framework) Web application and I am including a webservice.

6条回答
  •  [愿得一人]
    2020-12-03 12:10

    1. turn the return type to void
    2. put your object onto ^_^
    [WebMethod]
    public static void GetDocuments()
    {
        HttpContext.Current.Response.ContentType = "application/json";
        HttpContext.Current.Response.Write(JsonConvert.SerializeObject( ^_^ ));
        HttpContext.Current.Response.End();
    }
    

提交回复
热议问题