title: How to let an ASMX file output JSON
body: <p>I created an ASMX file with a code behind file. It's working fine, but it is outputting XML.</p>
  
  <p>However, I need it to output JSON. The ResponseFormat configuration doesn't seem to work. My code-behind is:</p>
  
  <pre><code>[System.Web.Script.Services.ScriptService]
  public class _default : System.Web.Services.WebService {
      [WebMethod]
      [ScriptMethod(UseHttpGet = true,ResponseFormat = ResponseFormat.Json)]
      public string[] UserDetails()
      {
          return new string[] { "abc", "def" };
      }
  }
  </code></pre>