[ScriptMethod(ResponseFormat = ResponseFormat.Json)]

后端 未结 1 1321
野趣味
野趣味 2020-12-11 18:46

In ASP.net web service if the above isn\'t specified , what is the response format by default? Also, if my web service below:

[WebMethod()]
        public Li         


        
相关标签:
1条回答
  • 2020-12-11 19:17

    The ResponseFormat attribute is not necessary. Including both client and server settings, only four things are required to do that:

    • Add the ScriptHandlerFactory HttpHandler in your web.config.
    • Decorate your web service(s) with the [ScriptService] attribute.
    • Request the service's methods with the POST verb.
    • Request the service's methods with a content-type of "application/json".

    When you do those four things, the service methods' responses will automatically be serialized as JSON.

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