title: ASP.Net Core 3.1: Controller method always recieves NULL parameter from HttpPost call
body: <p>I've created a brand new Visual Studio 2019 web app using ASP.Net Core 3.1 with an MVC pattern.  </p>
  
  <p>My controller has an HttpPost method that should have an incoming Json object (I use [FromBody] for the incoming parameter).</p>
  
  <p>No matter what I try, the incoming parameter is always Null.  I've tried changing the parameter to a string, and modifying the Model to be a simple 3 field class, but it still comes in as a null.</p>
  
  <p>I used Chrome's Developer Tools to make sure that my page is sending the Json object correctly from a JavaScript Post callback (and also used Postman to do the same) with the same result:  my parameter is still Null.</p>
  
  <p>What do I need to do to get the parameter to come in as an actual value?</p>
  
  <p>My controller:</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Threading.Tasks;
  using Microsoft.AspNetCore.Mvc;
  using Newtonsoft.Json;
  
  using canvasApiLib.API;
  using CanvasGrades.Models.AuxiliaryModels;
  
  namespace CanvasGrades.Controllers
  {
      public class FinalGradeController : Controller
      {
  
          public async Task&lt;IActionResult&gt; Index()
          {
              // Course Name
              dynamic courseDetails = await clsCoursesApi.getCourseDetails(accessToken, apiUrl, canvasCourseId);
              ViewData["CourseName"] = courseDetails.name;
  
              // Course Term
              dynamic courseTerm = await clsEnrollmentTermsApi.getEnrollmentTerm(accessToken, apiUrl, canvasAccountID, termNum);
              ViewData["CourseTerm"] = courseTerm.name;
  
              return View();
          }
  
          [HttpPost]
          public async Task&lt;IActionResult&gt; LoadTable([FromBody]DTParameters dtParameters)
          {
              //DTParameters dtParameters = new DTParameters();
  
              if (dtParameters == null)
              {
                  dtParameters = new DTParameters();
              }
          }
      }
  }
  </code></pre>
  
  <p>My DTParameters model:</p>
  
  <pre><code>public class DTParameters
  {
      public int Draw { get; set; }
      public DTColumn[] Columns { get; set; }
      public DTOrder[] Order { get; set; }
      public int Start { get; set; }
      public int Length { get; set; }
      public DTSearch Search { get; set; }
      public IEnumerable&lt;string&gt; AdditionalValues { get; set; }
  }
  </code></pre>
  
  <p>Most examples that I saw stated to tweak the app.UseMVC instantiation in the Configure call of the Startup.cs file, but mine doesn't have one:</p>
  
  <pre><code>// This method gets called by the runtime. Use this method to add services to the container.
  public void ConfigureServices(IServiceCollection services)
  {
      services.AddDistributedMemoryCache();
      services.AddControllersWithViews();
  }
  
  // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
  public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
  {
      if (env.IsDevelopment())
      {
          app.UseDeveloperExceptionPage();
      }
      else
      {
          app.UseExceptionHandler("/Home/Error");
          // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
          app.UseHsts();
      }
  
      app.UseHttpsRedirection();
      app.UseStaticFiles();
  
      app.UseRouting();
  
      app.UseAuthorization();
  
      app.UseEndpoints(endpoints =&gt;
      {
          endpoints.MapControllerRoute(
              name: "default",
              pattern: "{controller=Home}/{action=Index}/{id?}");
      });
  }
  </code></pre>
  
  <p>(ADDED)</p>
  
  <pre><code>{"draw":1,"columns":[{"data":"studentName","name":"","searchable":true,"orderable":true,"search":{"value":"","regex":false}},{"data":"studentEMail","name":"","searchable":true,"orderable":true,"search":{"value":"","regex":false}},{"data":null,"name":"","searchable":true,"orderable":true,"search":{"value":"","regex":false}},{"data":"finalGrade","name":"","searchable":true,"orderable":true,"search":{"value":"","regex":false}},{"data":"lastAttendDate","name":"","searchable":true,"orderable":true,"search":{"value":"","regex":false}},{"data":null,"name":"","searchable":true,"orderable":true,"search":{"value":"","regex":false}},{"data":null,"name":"","searchable":true,"orderable":true,"search":{"value":"","regex":false}},{"data":"bannerID","name":"","searchable":true,"orderable":true,"search":{"value":"","regex":false}},{"data":"crn","name":"","searchable":true,"orderable":true,"search":{"value":"","regex":false}}],"order":[{"column":0,"dir":"asc"}],"start":0,"length":10,"search":{"value":"","regex":false}}
  </code></pre>
  
  <p>I retried my simple parameter again, noticing that original ID field that I sent was an integer, but when I made it a string (like the Model stated) it came in with no issue.</p>
  
  <pre><code>public class SimpleParam
  {
      public string Id { get; set; }
      public string Name { get; set; }
      public string Foo { get; set; }
  }
  
  {"id": "1", "name": "fred", "foo": "bob"}
  </code></pre>
  
  <p>So, that means I'm going to have to figure out what's wrong with my DTParameters model.</p>