title: Model binding is not working on POST request in ASP.NET Core 2 WebAPI
body: <p>This is my model.</p>
  
  <pre><code>public class Patient
  {
    public string Name { get; set; }
    public string Gender { get; set; }
    public double Age { get; set; }
    public DateTime DateOfBirth { get; set; }
    public string MobileNumber { get; set; }
    public string Address { get; set; }
    public string Occupation { get; set; }
    public string BloodGroup { get; set; } 
  }
  </code></pre>
  
  <p>And this is the POST request intercepted by Fiddler
  <a href="https://i.stack.imgur.com/QQuHJ.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/QQuHJ.jpg" alt="enter image description here"></a></p>
  
  <p>And this is my controller.</p>
  
  <pre><code>[Produces("application/json")]
  [Route("api/Patient")]
  public class PatientController : Controller
  {        
      [HttpPost]
      public IActionResult Post([FromBody] Patient patient)
      {
         //Do something with patient
          return Ok();
      }
  }
  </code></pre>
  
  <p>My problem is I'm always getting <code>null</code> for <code>patient</code> in <code>[FromBody] Patient patient</code></p>
  
  <p><strong>EDIT 1</strong>:
  According to ingvar's comment I've made JSON of request body like following: </p>
  
  <p><code>{patient: {"name":"Leonardo","gender":"",....,"bloodGroup":""}}</code>
  but this time I gate default value of the properties (eg. <code>name: ""</code> and <code>age: 0</code>)</p>
  
  <p><strong>EDIT 2</strong>:
  My <code>ConfigureServices</code> and <code>Configure</code> method in Startup.cs file</p>
  
  <pre><code>    public IServiceProvider ConfigureServices(IServiceCollection services)
      {
          services.AddCors();
          services.AddMvc();
  
          var containerBuilder = new ContainerBuilder();
          containerBuilder.RegisterType&lt;PatientRepository&gt;().As&lt;IPatientRepository&gt;();
          containerBuilder.RegisterType&lt;UnitOfWork&gt;()
              .As&lt;IUnitOfWork&gt;()
              .WithParameter("connectionString", Configuration.GetConnectionString("PostgreConnection"));                
          containerBuilder.Populate(services);
          var container = containerBuilder.Build();
          return new AutofacServiceProvider(container);
      }
  
      public void Configure(IApplicationBuilder app, IHostingEnvironment env)
      {
          if (env.IsDevelopment())
          {
              app.UseDeveloperExceptionPage();
          }
          app.UseCors(corsPolicyBuilder =&gt;
              corsPolicyBuilder.WithOrigins("http://localhost:3000")
              .AllowAnyMethod()
              .AllowAnyHeader());
          app.UseMvc();
      }
  </code></pre>