title: Return JsonResult with List of objects from MVC controller
body: <p>I have a simple method in my MVC controller:</p>
  
  <pre><code>[HttpPost]
  public JsonResult GetAreasForCompany(int companyId)
  {
     var areas = context.Areas.Where(x =&gt; x.Company.CompanyId == companyId).ToList();
     return Json(areas);
  }
  </code></pre>
  
  <p>This is an area object:</p>
  
  <pre><code>public class Area
  {
      public int AreaId { get; set; }
  
      [Required]
      public string Title { get; set; }
      public bool Archive { get; set; }
  
      public virtual Company Company { get; set; }
  }
  </code></pre>
  
  <p>And this is how I call the method from the view:</p>
  
  <pre><code>$.ajax({
      url: '@Url.Action("GetAreasForCompany")',
      type: 'POST',
      async: false,
      data: "{'companyId': " + companyId + "}",
      dataType: 'json',
      contentType: 'application/json; charset=utf-8',
      error: function () {
          alert("Server access failure!");
      },
      success: function (result) {
          response = result;
      }
  });
  </code></pre>
  
  <p>I have checked the method in the controller and a list of Area objects gets created. Would you have any idea why do I get the 500 internal server error when the method is called from the view? When I return anything else (like a Dictionary object) everything works fine, it's just when I aim to convert the List of Areas into Json I get an error.</p>