title: How do I remove carriage returns from the JSON output of my WebAPI service?
body: <p>I have created a Web API service that outputs JSON which is to be consumed by a KendoUI datagrid. Here's the rub: the KendoUI datagrid is VERY picky about the JSON code it consumes; it must not have any kind of carriage returns/line feeds. It has to be one big block of unformatted JSON.</p>
  
  <p>We worked with someone from Telerik and they set up some kind of proxy (<a href="https://cors.io/?http://js01.consultwithus.us/odata/vw_FilesToBeProcessed_Dashboard" rel="nofollow noreferrer">https://cors.io/?http://js01.consultwithus.us/odata/vw_FilesToBeProcessed_Dashboard</a>), but it's just a band-aid.</p>
  
  <pre><code>public static class WebApiConfig
  {
      public static void Register(HttpConfiguration config)
      {
          // Web API configuration and services
  
          // Web API routes
          config.MapHttpAttributeRoutes();
  
          // enable CORS
          config.EnableCors();
  
          config.Routes.MapHttpRoute(
              name: "DefaultApi",
              routeTemplate: "api/{controller}/{id}",
              defaults: new { id = RouteParameter.Optional }
          );
  
          // we must set odata to version 2
          var vers = new Version(2, 0);
  
          ODataConventionModelBuilder builder = new ODataConventionModelBuilder();
          builder.DataServiceVersion = vers;
          builder.MaxDataServiceVersion = vers;
          builder.EntitySet&lt;vw_FilesToBeProcessed_Dashboard&gt;("vw_FilesToBeProcessed_Dashboard");
          config.Routes.MapODataServiceRoute("odata", "odata", builder.GetEdmModel());
      }
  }
  </code></pre>
  
  <p>I want my output to look like <a href="https://cors.io/?http://js01.consultwithus.us/odata/vw_FilesToBeProcessed_Dashboard" rel="nofollow noreferrer">this</a>, but right now it just looks like <a href="http://js01.consultwithus.us/odata/vw_FilesToBeProcessed_Dashboard" rel="nofollow noreferrer">this</a>.</p>
  
  <hr>
  
  <p>UPDATE 12/28/2018</p>
  
  <p>Here is the code for my controller:</p>
  
  <pre><code>[EnableCors(origins: "http://js01.consultwithus.us", headers: "*", methods: "*")]
  public class vw_FilesToBeProcessed_DashboardController : ODataController
  {
      private CSS_DevEntities db = new CSS_DevEntities();
  
      // GET: odata/vw_FilesToBeProcessed_Dashboard
      [EnableQuery]
      public IQueryable&lt;vw_FilesToBeProcessed_Dashboard&gt; Getvw_FilesToBeProcessed_Dashboard()
      {
          return db.vw_FilesToBeProcessed_Dashboard;
      }
  
      // GET: odata/vw_FilesToBeProcessed_Dashboard(5)
      [EnableQuery]
      public SingleResult&lt;vw_FilesToBeProcessed_Dashboard&gt; Getvw_FilesToBeProcessed_Dashboard([FromODataUri] int key)
      {
          return SingleResult.Create(db.vw_FilesToBeProcessed_Dashboard.Where(vw_FilesToBeProcessed_Dashboard =&gt; vw_FilesToBeProcessed_Dashboard.Files_PK == key));
      }
  
      // PUT: odata/vw_FilesToBeProcessed_Dashboard(5)
      public IHttpActionResult Put([FromODataUri] int key, Delta&lt;vw_FilesToBeProcessed_Dashboard&gt; patch)
      {
          Validate(patch.GetEntity());
  
          if (!ModelState.IsValid)
          {
              return BadRequest(ModelState);
          }
  
          vw_FilesToBeProcessed_Dashboard vw_FilesToBeProcessed_Dashboard = db.vw_FilesToBeProcessed_Dashboard.Find(key);
          if (vw_FilesToBeProcessed_Dashboard == null)
          {
              return NotFound();
          }
  
          patch.Put(vw_FilesToBeProcessed_Dashboard);
  
          try
          {
              db.SaveChanges();
          }
          catch (DbUpdateConcurrencyException)
          {
              if (!vw_FilesToBeProcessed_DashboardExists(key))
              {
                  return NotFound();
              }
              else
              {
                  throw;
              }
          }
  
          return Updated(vw_FilesToBeProcessed_Dashboard);
      }
  
      // POST: odata/vw_FilesToBeProcessed_Dashboard
      public IHttpActionResult Post(vw_FilesToBeProcessed_Dashboard vw_FilesToBeProcessed_Dashboard)
      {
          if (!ModelState.IsValid)
          {
              return BadRequest(ModelState);
          }
  
          db.vw_FilesToBeProcessed_Dashboard.Add(vw_FilesToBeProcessed_Dashboard);
  
          try
          {
              db.SaveChanges();
          }
          catch (DbUpdateException)
          {
              if (vw_FilesToBeProcessed_DashboardExists(vw_FilesToBeProcessed_Dashboard.Files_PK))
              {
                  return Conflict();
              }
              else
              {
                  throw;
              }
          }
  
          return Created(vw_FilesToBeProcessed_Dashboard);
      }
  
      // PATCH: odata/vw_FilesToBeProcessed_Dashboard(5)
      [AcceptVerbs("PATCH", "MERGE")]
      public IHttpActionResult Patch([FromODataUri] int key, Delta&lt;vw_FilesToBeProcessed_Dashboard&gt; patch)
      {
          Validate(patch.GetEntity());
  
          if (!ModelState.IsValid)
          {
              return BadRequest(ModelState);
          }
  
          vw_FilesToBeProcessed_Dashboard vw_FilesToBeProcessed_Dashboard = db.vw_FilesToBeProcessed_Dashboard.Find(key);
          if (vw_FilesToBeProcessed_Dashboard == null)
          {
              return NotFound();
          }
  
          patch.Patch(vw_FilesToBeProcessed_Dashboard);
  
          try
          {
              db.SaveChanges();
          }
          catch (DbUpdateConcurrencyException)
          {
              if (!vw_FilesToBeProcessed_DashboardExists(key))
              {
                  return NotFound();
              }
              else
              {
                  throw;
              }
          }
  
          return Updated(vw_FilesToBeProcessed_Dashboard);
      }
  
      // DELETE: odata/vw_FilesToBeProcessed_Dashboard(5)
      public IHttpActionResult Delete([FromODataUri] int key)
      {
          vw_FilesToBeProcessed_Dashboard vw_FilesToBeProcessed_Dashboard = db.vw_FilesToBeProcessed_Dashboard.Find(key);
          if (vw_FilesToBeProcessed_Dashboard == null)
          {
              return NotFound();
          }
  
          db.vw_FilesToBeProcessed_Dashboard.Remove(vw_FilesToBeProcessed_Dashboard);
          db.SaveChanges();
  
          return StatusCode(HttpStatusCode.NoContent);
      }
  
      protected override void Dispose(bool disposing)
      {
          if (disposing)
          {
              db.Dispose();
          }
          base.Dispose(disposing);
      }
  
      private bool vw_FilesToBeProcessed_DashboardExists(int key)
      {
          return db.vw_FilesToBeProcessed_Dashboard.Count(e =&gt; e.Files_PK == key) &gt; 0;
      }
  }
  </code></pre>
  
  <p>I had Visual Studio scaffold this for me based on my EDM.</p>