title: ObjectResult containing list of objects in ASP.NET MVC6 Web Api
body: <p>I'm getting to grips creating an API using MVC 6.  I have several simple response models for which I'm using an <code>ObjectResult</code> as follows:</p>
  
  <pre><code>[Route("api/foos")]
  public class FooController : Controller
  {
      [HttpGet]
      public IActionResult GetFoos()
      {
          return new ObjectResult(FooRepository.GetAll().Select(FooModel.From));
      }
  }
  </code></pre>
  
  <p>And this works fine when <code>FooModel</code> is a simple model containing a few properties and even a list of simple types, like strings.  </p>
  
  <p>However, I am now trying to follow a similar pattern where <code>FooModel</code> contains a list of other objects within it, and I'd like to show the details of these nicely formatted in my JSON response, as an array of objects. However, with the following classes I get "No response recieved".</p>
  
  <pre><code>public class FooModel
  {
      public Guid Id { get; set; }
      public string Name { get; set; }
      public List&lt;Bar&gt; Bars { get; set; }
      public FooModel(Guid id, string name, List&lt;Bar&gt; bars)
      {
          this.Id = id;
          this.Name = name;
          this.Bars = bars;
      }
      internal static FooModel From(Foo foo)
      {
          return new FooModel(foo.Id, foo.Name, foo.Bars);
      }
  }
  
  public class BarModel
  {
      public Guid Id { get; set; }
      public string Name { get; set; }
      public BarModel(Guid id, string name)
      {
          this.Id = id;
          this.Name = name;
      }
      internal static BarModel From(Bar bar)
      {
          return new BarModel(bar.Id, bar.Name);
      }
  }
  </code></pre>
  
  <p>If I change the <code>List&lt;Bar&gt;</code> to a list of strings, the response displays a JSON array of strings nicely. How can I get my response to return the the list of inner object as an array of objects in my JSON response?</p>