ASP.NET WebMethod Returns JSON wrapped in quotes

前端 未结 3 1427
挽巷
挽巷 2020-12-15 00:53

I have an asp.net page with a WebMethod on it to pass JSON back to my javascript.

Bellow is the web method:

[WebMethod]
public static string getData         


        
3条回答
  •  Happy的楠姐
    2020-12-15 01:36

    Actually this entire issue exists because you're trying to out-think ASP.Net web services. You need to setup a class for your data to be returned and use that class (or List(of YourClass)) to queue up results and return them.

    A great article explaining all this (a very common pitfall) is: http://encosia.com/asp-net-web-services-mistake-manual-json-serialization/

提交回复
热议问题