title: How to force ASMX web service to send JSON data to client on HTTP GET request?
body: <p>I'm trying to use the official <a href="http://docs.jquery.com/Plugins/Autocomplete" rel="nofollow noreferrer">jQuery autocomplete plugin</a> with an ASMX web service in an ASP.NET 3.5 Web Forms application. If I understand it correctly, the autocomplete plugin can only use HTTP GET to call a service (with two query string parameters: <em>q</em> and <em>limit</em>). I figured out how to make the web service respond to the HTTP GET calls, but I cannot figure out how to make it return JSON data (even though the service returns JSON data when I call it using jQuery $.ajax with type='POST', when called from the autocomplete plugin it always returns XML). Here are some code snippets:</p>
  
  <p>Web service:</p>
  
  <pre><code>[ScriptService]
  [WebService(Namespace = "http://tempuri.org/")]
  public class UserWS: WebService
  {
    [WebMethod]
    [ScriptMethod(UseHttpGet=true, ResponseFormat=ResponseFormat.Json)]
    public List&lt;UserDisplayInfo&gt; GetUsers
    (
      string q,
      int limit
    )
    {
      List&lt;UserDisplayInfo&gt;users = GetUsers(q, limit);
      return users.ToList();
    }
  }
  </code></pre>
  
  <p>Web page:</p>
  
  <pre><code>$("#test").autocomplete(
    "./Services/UserWS.asmx/GetUsers",
    {
      dataType: 'json',
      type: 'POST', // this setting is ignored
      contentType: 'application/json;charset=utf-8',
      parse: function(data) 
      {
        //...
      }
  });
  </code></pre>
  
  <p>If this is not possible I wonder what would be a better alternative:</p>
  
  <ul>
  <li>fixing autocomplete plugin to use HTTP POST and JSON data instead of GET and query string parameters;</li>
  <li>using a different autocomplete plugin (I looked at a few, but at this point the official plugin has most recommendations, and I'm not sure if other plugins support HTTP POST);</li>
  <li>an alternative to ASMX web service, such as WCF web service (I would not want to use WCF because ASMX web service is simpler to implement -- no web.config changes, no contracts, no interfaces -- and it gives me everything I need); </li>
  <li>something else.</li>
  </ul>
  
  <p>I found several similar questions at StackOverflow, but I did not find the answer that would work for me. Any (good) ideas?</p>