title: ASP.NET JSON web service always return the JSON response wrapped in XML
body: <p>I saw a similar question but it did not resolve my issue. I have a JSON web service in an ASMX file; </p>
  
  <p>The code for the web method</p>
  
  <pre><code>        [WebMethod]
          [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
          public string GetUserRoles(string JSONUserCode)
          {
              string retRoles = string.Empty;
              List&lt;JSONRole&gt; roles = new List&lt;JSONRole&gt;();
  
              {... I Populate the roles here ...}
  
              DataContractJsonSerializer serializer = new
              DataContractJsonSerializer(roles.GetType());
              MemoryStream ms = new MemoryStream();
              serializer.WriteObject(ms, roles);
              string jsonString = Encoding.Default.GetString(ms.ToArray());
              ms.Close();
              return jsonString;
          }
  </code></pre>
  
  <p>This correctly formats the List correctly but wraps the entire return in XML. Here is the response:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8" ?&gt; 
      &lt;string xmlns="http://formshare.com/"&gt;
         [{"Name":"Accounts Payable"},{"Name":"Payroll"}]
      &lt;/string&gt;
  </code></pre>
  
  <p>You can view the Response your self by clicking this link:</p>
  
  <p><a href="http://dev.formshare.gologictech.com/JSON/JSONService.asmx/GetUserRoles?JSONUserCode=1234" rel="noreferrer">http://dev.formshare.gologictech.com/JSON/JSONService.asmx/GetUserRoles?JSONUserCode=1234</a></p>
  
  <p>I need the response to be just:</p>
  
  <pre><code>[{"Name":"Accounts Payable"},{"Name":"Payroll"}]
  </code></pre>
  
  <p>Any ideas? Thanks for your help.</p>