title: ASP .NET Web API Returning JSON file
body: <p>I am creating a ASP.NET Web API service end point where it queries the Oracle Database and returns the result in JSON format.</p>
  
  <p>Below is the code I am using in the Controller</p>
  
  <pre><code>public class SampleController : ApiController
  {
    public HttpResponseMessage Getdetails([FromUri] string[] id)
    {
      using (OracleConnection dbconn = new OracleConnection("DATA SOURCE=J;PASSWORD=C;PERSIST SECURITY INFO=True;USER ID=T"))
      {
          var inconditions = id.Distinct().ToArray();
          var srtcon = string.Join(",", inconditions);
          DataSet userDataset = new DataSet();
          var strQuery = @"SELECT * from STCD_PRIO_CATEGORY where STPR_STUDY.STD_REF IN(" + srtcon + ")";
          OracleCommand selectCommand = new OracleCommand(strQuery, dbconn);
          OracleDataAdapter adapter = new OracleDataAdapter(selectCommand);
          DataTable selectResults = new DataTable();
          adapter.Fill(selectResults);
          string result = JsonConvert.SerializeObject(selectResults);
          string contentDisposition = "inline; filename=ProvantisStudyData.json";
          //byte[] byteInfo = Encoding.ASCII.GetBytes(result);
          HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK, result, MediaTypeHeaderValue.Parse("application/json"));
          response.Content.Headers.ContentDisposition = ContentDispositionHeaderValue.Parse(contentDisposition);
          //response.Content.Headers.ContentLength = byteInfo.Length;
          return response;
   }
  }
  </code></pre>
  
  <p>Everything works fine, except that it returns result is in the below format</p>
  
  <blockquote>
    <p>"[{\"CATEGORY\":\"Internal
    Study\",\"SESSION_NUMBER\":7,\"SESSION_START_DATE\":\"2015-02-13T00:00:00\",\"SESSION_START_TIME\":\"2015-02-13T10:33:59.288394\",\"SESSION_END_DATE\":\"2015-02-13T00:00:00\",\"SESSION_END_TIME\":\"2015-02-13T12:11:34\"}]"</p>
  </blockquote>
  
  <p>It is just that it creates the extra quotes and the extra escaping characters (<code>\</code>). Do I need to do the manipulation to have them removed.</p>
  
  <blockquote>
    <p>[{"CATEGORY":"Internal
    Study","SESSION_NUMBER":7,"SESSION_START_DATE":"2015-02-13T00:00:00","SESSION_START_TIME":"2015-02-13T10:33:59.288394","SESSION_END_DATE":"2015-02-13T00:00:00","SESSION_END_TIME":"2015-02-13T12:11:34"}]</p>
  </blockquote>