title: WebApi serialization depth and circular reference
body: <p>I have a few composed object being returned on a WebApi Restful service (for simplicity):</p>
  
  <pre><code>class Item {
      List&lt;Category&gt; Categories { get; set; }
      object Value { get; set; }
  }
  
  class Category {
      List&lt;Item&gt; ItemsInCategory { get; set; }
  }
  </code></pre>
  
  <p>These values are being served by a simple ApiController:</p>
  
  <pre><code> publicHttpResponseMessage getItems()
   {
       List&lt;Category&gt; categories;
       ...
       return Request.CreateResponse(HttpStatusCode.OK, new { results = items});
   }
  </code></pre>
  
  <p>The problem: Say Item(A) is in Category(A) this will result a circular dependency which will "stuck" the serialization. Therefore the webapi team (which is the last time I am using as a backend B.T.W) has exposed reference loop handling: (WebApiConfig.cs)</p>
  
  <pre><code>JsonMediaTypeFormatter jsonFormatter = GlobalConfiguration.Configuration.Formatters.JsonFormatter;
  var jSettings = new JsonSerializerSettings()
       {
          Formatting = Formatting.Indented,
          DateTimeZoneHandling = DateTimeZoneHandling.Utc,
          ReferenceLoopHandling = ReferenceLoopHandling.Ignore,
       };
  
  jsonFormatter.SerializerSettings = jSettings;
  </code></pre>
  
  <p>That said it doesn't really work.
  Nor the "MaxDepth" property. <br/>
  I've searched many ways and couldn't find a built-in way to achieve this (there are many "hacking") that achieve some variations of JsonConverter (and also [JsonIgnore]) that help achieve some proportions of this.<br/>
  This is a <strong>VERY</strong> common request to control the depth of the response, isn't it?<br/>
  Any chance Microsoft has completely ignored this issue and there is no built in way to deal with this issue???? </p>