title: Return complex object from .Net core API
body: <p>I'm using a .Net core backend with Entity Framework to retrieve objects to my angular2 frontend.
  As long as I return flat objects from the backend I have not problems. But when I use an Linq <code>Include</code> I get an <code>net::ERR_CONNECTION_RESET</code> error. The error seems to occur as soon as the call returns from backend, but it never enters the result handler.</p>
  
  <p>How can I return a complex object with lists inside the objects?</p>
  
  <p><em>DocumentsController.cs:</em></p>
  
  <pre><code>[Produces("application/json")]
  [Route("api/[controller]")]
  public class DocumentsController : Controller
  {
      private readonly DatabaseContext _context;
  
      public DocumentsController(DatabaseContext context)
      {
          _context = context;
      }
  
      // GET: api/Documents
      [HttpGet]
      public IEnumerable&lt;Document&gt; GetDocuments()
      {
          var documents = _context.Documents
              .Include(x =&gt; x.Pages);
  
          return documents;
      }
  }
  </code></pre>
  
  <p><em>Document.cs:</em></p>
  
  <pre><code>public class Document : IEntity
  {
      public int Id { get; set; }
      public string Title { get; set; }
      public string AlternativeTitle { get; set; }
      public ICollection&lt;Page&gt; Pages { get; set; }
  }
  </code></pre>
  
  <p><em>Page.cs:</em></p>
  
  <pre><code>public class Page : IEntity
  {
      public Document Document { get; set; }
      public int DocumentId { get; set; }
      public int Id { get; set; }
      public string OriginalText { get; set; }
      public int Sorting { get; set; }
  }
  </code></pre>
  
  <p><em>documents.components.ts:</em></p>
  
  <pre><code>import { Component, Inject } from '@angular/core';
  import { Http } from '@angular/http';
  
  @Component({
      selector: 'documents',
      templateUrl: './documents.component.html'
  })
  export class DocumentsComponent {
      public documents: Document[];
  
      constructor(http: Http, @Inject('BASE_URL') baseUrl: string) {
          http.get(baseUrl + 'api/Documents').subscribe(result =&gt; {
              this.documents = result.json() as Document[];
          }, error =&gt; console.error(error));
      }
  }
  
  interface Document {
      title: string;
      alternativeTitle: string;
      pageCount: number;
      pages: Array&lt;Page&gt;;
  }
  interface Page {
      originalText: string;
      sorting: number;
  }
  </code></pre>