title: ASMX webservice not returning JSON, can only POST using application/x-www-form-urlencoded contentType
body: <p>I can call my webservice using jQuery IF the contentType = "application/x-www-form-urlencoded; charset=utf-8"</p>
  
  <p>This will, however, return the xml: <code>&lt;string&gt;[myjson]&lt;/string&gt;</code> </p>
  
  <p>If I try to POST to the service using "application/json; charset=utf-8" I receive a 500 error with an empty StackTrace and ExceptionType. My webservice function is never hit so I'm not quite sure how to debug this situation.</p>
  
  <p>My methods and classes are decorated with the appropriate attributes and are set to use JSON as their response type (as do my wsdl and disco files). I have the Ajax extensions installed and the required entries in web.config. </p>
  
  <p>This is on a SharePoint farm, but I'm not sure that makes too much of a difference. I deployed the web.config changes on all WFE's as well as installed the ajax extensions. Again the service works, it just will not accept anything but the default content type.</p>
  
  <p>Not sure what I'm missing here, fellas...</p>
  
  <p>my ajax call:</p>
  
  <pre><code>$.ajax({
  type: "POST",
  url: "/_vti_bin/calendar.asmx/Test",
  dataType: "json",
  data: "{}",
  contentType: "application/json; charset=UTF-8",
  success: function(msg){
      alert(msg);
      },
  error: function(xhr, msg){ alert(msg + '\n' + xhr.responseText); }
  });
  </code></pre>
  
  <p>My webservice class:</p>
  
  <pre><code>[WebService(Namespace = "http://namespace")]
  [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
  [ScriptService()]
  public class CalendarService : WebService
  {
      [WebMethod]
      [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
      public string Test()
      {
          return "Hello World";
      }
  }
  </code></pre>