asp.net - How to force ASMX web service to send JSON data to client on HTTP GET request? -


I am trying to use official with ASMX web service in ASPNT 3.5 web form application. If I understand it correctly, then the auto-complete plugin can use HTTP GET to call only one service (with two query string parameters: q and range ). I came to know how the Web service responds to the HTTP GET call, but I did not know how this can return JSON data (even if the service calls it using JS $ $ data.), When calling from the complete plugin, it always gives XML). Here are some code snippets:

Web service:

  [ScriptService] [WebServices (namespace = "http://tempuri.org/")] Public class UserWS: WebService {[WebMethod] [ScriptMethod (Use HTTPPat = true, response format = response format. Jason)] Public list & amp; YouTube Dislike Menu & gt; GetUnivers (string q, int limit) {list & lt; UserDisplayInfo & gt; User = GetUsers (Q, Border); Return users. }}  

Web page:

  $ ("# test"). Autocomplete ("./services/UserWS.asmx/GetUsers", {dataType: 'Jason', type: 'POST', // This setting is ignored by the content type: 'application / json; charset = utf- 8 ', pars: function (data) {// ...}});  

If this is not possible, then I wonder what would be a better option:

  • Using HTTP POST and JSON data instead of GTE and query Fix the auto-complete plugin for string parameters;
  • Using a different autoplayplate plugin (I looked at something, but this time the official plugin has the most recommendations, and I'm not sure other plugins support HTTP posts);
  • An alternative to the ASMX web service, such as WCF Web Services (I would not like to use WCF because the ASMX web service is easy to implement - no web configured change, no contract, no Not the interface - and it gives me everything I need);
  • Something else

I got many similar questions on the stack overflow, but I did not find the answer to the answer that would work for me any (good) idea?

Autocomplete plugin should result in plain text format, not JSON. Each item should be on a separate row:

  foo \ n times \ nbaz \ n  

with the generic handler (.sx) web service Try changing:

  Public class MyHandler: IHttpHandler {public void ProcessRequest (HttpContext reference) {context.Response.ContentType = "text / plain"; Context.Response.Write ("foo \ Nbar \ nbaz"); } Public Child IRUUL (see {return incorrect;}}}  

See if you want ASMX web service to return JSN, you can not use GET. / P>


Comments

Popular posts from this blog

c# - ListView onScroll event -

PHP - get image from byte array -

Linux Terminal Problem with Non-Canonical Terminal I/O app -