title: Why a value of false for IsSuccessStatusCode when the request appears successful?
body: <p>I have a WPF client using an ASP.NET Web API 2 as a central server. In the Web API, I have this action:</p>
  
  <pre><code>[HttpPost]
  public IHttpActionResult Get()
  {
      IEnumerable&lt;Person&gt; persons;
      try
      {
          persons = Db.People.ToList();
      }
      catch (Exception ex)
      {
          return new ExceptionResult(ex, this);
      }
      return Ok(persons);
  }
  </code></pre>
  
  <p>When I step through this method, it exits on <code>return Ok(persons);</code>, and the debug I am following returns to the WPF client, where the response has <code>IsSuccessStatusCode == false</code>, with a status of "500 Internal Server Error" and nothing anywhere in the response explaining why?</p>
  
  <p>I call this action with a generic method:</p>
  
  <pre><code>People = await Rest.PostAsync&lt;IEnumerable&lt;Person&gt;&gt;("/api/Persons");
  ...
  public async Task&lt;TReturn&gt; PostAsync&lt;TReturn&gt;(string resource)
  {
      var exMsg = $"Post request failed to get resource: '{resource}' from '{Client.BaseAddress}'.";
      try
      {
          HttpResponseMessage response = await Client.PostAsync(resource, null);
          if (!response.IsSuccessStatusCode)
          {
              Logger.Error(exMsg);
              RaiseException(response, exMsg);
          }
          return JsonConvert.DeserializeObject&lt;TReturn&gt;(await response.Content.ReadAsStringAsync());
      }
      catch (Exception ex) when (ex.GetType() != typeof(RestClientException))
      {
          Logger.Error(ex, exMsg);
          throw;
      }
  }
  </code></pre>
  
  <p>I don't use the ugly, blanket <code>response.EnsureSuccessStatusCode()</code> because I've been lead to believe it causes information in the response to be lost.</p>
  
  <p>This was still working, an hour ago, with no code changes except columns in a <code>DataGrid</code>, and maybe somehow, the fact that I changed data in the database, but not any of the data model components in the solution. Only data values, and then sure the <code>ToList()</code> in the action method would pull any data gremlins out of the woodwork.</p>
  
  <p>I can only figure the HTTP 500 happens between the controller and the client, and I'm asking what could be wrong, and how can I diagnose it?</p>