title: JsonResult not returning data after Ajax call in .NET Core Razor Page
body: <p>I'm trying to return data from a <code>JsonResult</code> method within my <strong>ASP.Net Core (3.1) Razor Page Application</strong> back to a Razor Page, however, I'm having problems.</p>
  <p>When I debug, I can see the <code>OnGetCarList</code> method within the Page Model being hit and no errors in the code when I step through, however,  when the data is returned to the <code>Ajax Success</code> function and output with an <code>alert</code>, this is what I see:</p>
  <p><a href="https://i.stack.imgur.com/4EiHB.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/4EiHB.png" alt="enter image description here" /></a></p>
  <p><strong>Ajax Call (within Razor Page)</strong></p>
  <pre><code>$.ajax({
            method: 'get',
            url: '/SPC/Index?handler=CarList',
            contentType: &quot;application/json&quot;,
            dataType: &quot;json&quot;,
            success: function (data) {
                  alert(data);
                  //addData(data)
                  }
         })
  </code></pre>
  <p><strong>Page Model</strong></p>
  <pre><code>public JsonResult OnGetCarList()
  {
      var converted = DateTime.Now.ToOADate();
  
      DateTime one = DateTime.Now;
      DateTime two = DateTime.Now.AddDays(1);
      DateTime three = DateTime.Now.AddDays(2);
  
      DateTime sTime = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
  
      var c_one = (long)(one - sTime).TotalMilliseconds;
      var c_two = (long)(two - sTime).TotalMilliseconds;
      var c_three = (long)(three - sTime).TotalMilliseconds;
  
      dataPoints = new List&lt;DataPoint&gt;();
  
      dataPoints.Add(new DataPoint(c_one, 100));
      dataPoints.Add(new DataPoint(c_two, 200));
      dataPoints.Add(new DataPoint(c_three, 300));
  
      return new JsonResult(dataPoints);
  }
  
  //DataContract for Serializing Data - required to serve in JSON format
  [DataContract]
  public class DataPoint
  {
      public DataPoint(double x, double y)
      {
          this.x = x;
          this.Y = y;
      }
  
      //Explicitly setting the name to be used while serializing to JSON.
      [DataMember(Name = &quot;x&quot;)]
      public Nullable&lt;double&gt; x = null;
  
      //Explicitly setting the name to be used while serializing to JSON.
      [DataMember(Name = &quot;y&quot;)]
      public Nullable&lt;double&gt; Y = null;
  }
  </code></pre>
  <p>Any guidance is appreciated.</p>
  <p>Thanks.</p>
  <p><strong>Update</strong></p>
  <p>I updated my Ajax call to what Serge said and now the <code>Alert</code> gives this.</p>
  <pre><code>$.ajax({
                  method: 'get',
                  url: '/SPC/Index?handler=CarList',
                  contentType: &quot;application/json&quot;,
                  dataType: &quot;json&quot;,
                  success: function (data) {
                      alert(JSON.stringify(data));
                      //addData(data)
                  }
         })
  </code></pre>
  <p><a href="https://i.stack.imgur.com/xJDtM.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/xJDtM.png" alt="enter image description here" /></a></p>