How do I return clean JSON from a WCF Service?

前端 未结 6 1087
借酒劲吻你
借酒劲吻你 2020-11-22 07:19

I am trying to return some JSON from a WCF service. This service simply returns some content from my database. I can get the data. However, I am concerned about the format

6条回答
  •  野趣味
    野趣味 (楼主)
    2020-11-22 08:13

    In your IServece.cs add the following tag : BodyStyle = WebMessageBodyStyle.Bare

     [WebInvoke(Method = "GET", ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Bare, UriTemplate = "Getperson/{id}")]
    
        List Getperson(string id);
    

提交回复
热议问题