title: MVC Controller Return Content vs Return Json Ajax
body: <p>In MVC, why does returning <code>Content</code> sometimes fail in the Ajax callback, while returning Json works, even for simple string objects?  </p>
  
  <p>Even when it fails, the data is still available if you were to access it in the always callback...</p>
  
  <h2>Update:</h2>
  
  <p>When I set the contentType in the ajax call to <code>text/xml</code> the response will no longer enter the error message.</p>
  
  <h2>AJAX:</h2>
  
  <pre><code>$.ajax({
      cache: false,
      type: "GET",
      contentType: "application/json; charset=utf-8",
      dataType: 'json',
      url: "/MyController/GetFooString",
      data: { },
      success: function (data) {
          alert(data);
      },
      error: function (xhr, ajaxOptions, thrownError) {
          alert("Ajax Failed!!!");
      }
  }); // end ajax call
  </code></pre>
  
  <h2>Controller Action That Fails (Sometimes)</h2>
  
  <p><em>Even when it fails, the data is still available.</em></p>
  
  <pre><code>public ActionResult GetFooString()
  {
      String Foo = "This is my foo string.";
      return Content(Foo);
  } // end GetFooString
  </code></pre>
  
  <h2>Controller Action That Always Works</h2>
  
  <pre><code>public ActionResult GetFooString()
  {
      String Foo = "This is my foo string.";
      return Json(Foo, JsonRequestBehavior.AllowGet);
  } // end GetFooString
  </code></pre>