title: ASP.NET C#, returning objects to Angular
body: <p>I am writing a C# api backend for an Angular front end. I have done this before in other projects and previously I have always just returned an object from the c# and in postman or Angular I was able to read the object. In postman, it was neatly formatted as json.</p>
  
  <p>For example, I used to have a <code>class Person</code> and a controller <code>PersonController</code>.  In <code>PersonController</code>, I could have a method <code>Get()</code> and the Get would be like this </p>
  
  <pre><code>public Person Get() {
      Person p = new Person();
      ...
      return p;
  }
  </code></pre>
  
  <p>and I should call the <code>PersonController.Get</code> from Angular and I would have the person. However for some reason, now I am doing this in a new project and all I am getting is <code>[Person]</code> -- not the expandable json.</p>
  
  <p>Why is this?</p>
  
  <p>I know I see that a diff. developer has spent time to return it as a string:</p>
  
  <pre><code>JavaScriptSerializer json = new JavaScriptSerializer()
              {
                  MaxJsonLength = 3000;
              };
  strJson = json.Serialize(model);
  return strJson;
  </code></pre>
  
  <p>But I want to return the actual object. I find parsing it made it much much slower.</p>
  
  <p>EDIT:</p>
  
  <p>This is my actual controller:</p>
  
  <pre><code> public class PersonController : Controller
   {
          private readonly IPersonService personService;
  
          public PersonController()
          {
              presonService =  new PersonService();
          }
  
          public async Task&lt;JArray&gt; Get(int? id)
          {
              var model = await personService.GetInfo(id, ConnHelper.ConnectionString());
              JArray a = (JArray)JToken.FromObject(model);
              return a;
              //return model;
          }
  
          public async Task&lt;List&lt;Person&gt;&gt; GetObject(int? id)
          {
                  var model = await personService.GetInfo(id, ConnHelper.ConnectionString());                
                  return model;
          }
  }
  </code></pre>