如何创建Web服务只返回json字符串?

时间:2013-01-27 11:03:32

标签: asp.net json web-services

我已将web.config设置为支持'get'请求。

<webServices>
  <protocols>
    <add name="HttpPost"/>
    <add name="HttpGet"/>
    <add name="HttpSoap"/>
    <add name="Documentation" />
  </protocols>
</webServices>

然后,我希望webservice只返回json字符串,而不是xml!但我已经设置

[ScriptMethod(ResponseFormat = ResponseFormat.Json,XmlSerializeString = false)]

它不起作用,仍然使用jsonstrings返回字符串....

我不想在页面文件中设置contentType,只需使用默认值!

0 个答案:

没有答案