title: Postman Form Data to ASP.NET Core 2.2 Controller not binding to Command with private setters
body: <p><strong>Tools</strong></p>
  
  <ul>
  <li>Visual Studio 2017</li>
  <li>ASP.NET Core 2.2</li>
  <li>Postman v7.2.0</li>
  </ul>
  
  <p><strong>What I'm trying to do</strong></p>
  
  <p>Send FormData from Postman to an ASP.NET Core controller and have the data from the request bind to to a command class that has properties with private setters.</p>
  
  <p>I've sent JSON data using the same setup (private setters) with no problem.  The <code>FromBody</code> attribute deserialises the JSON string to the model without errors.</p>
  
  <p><strong>The Problem</strong></p>
  
  <p>Properties that are primitive types do not bind if the model has a private setter.  However, complex types do regardless of the access modifier.</p>
  
  <p><strong>Controller</strong></p>
  
  <pre class="lang-cs prettyprint-override"><code>[HttpPost]
  [ProducesResponseType((int)HttpStatusCode.OK)]
  [ProducesResponseType((int)HttpStatusCode.BadRequest)]
  public async Task&lt;IActionResult&gt; CreateItemAsync([FromForm]CreateItemCommand command)
  {
      bool result = false;
  
      commandResult = await _mediator.Send(command);
  
      if (!commandResult)
      {
          return BadRequest();
      }
  
      return Ok();
  }
  </code></pre>
  
  <p><strong>Command</strong></p>
  
  <p>Note: The <code>Title</code> property has been left with a public setter deliberately to illustrate the behviour</p>
  
  <pre class="lang-cs prettyprint-override"><code>[DataContract]
  public class CreateItemCommand
      :IRequest&lt;bool&gt;
  {
      [DataMember]
      public string Title { get; set; }
  
      [DataMember]
      public string Description { get; private set; }
  
      [DataMember]
      public int Count { get; private set; }
  
      [DataMember]
      public HashSet&lt;string&gt; Tags { get; private set; }
  
      [DataMember]
      public string ItemDate { get; private set; }
  
      [DataMember]
      public List&lt;IFormFile&gt; Documents { get; private set; }
  
      public CreateItemCommand()
      {
          Skills = new HashSet&lt;string&gt;();
          Systems = new HashSet&lt;string&gt;();
      }
  
      public CreateItemCommand(string title, string description, 
          int count, HashSet&lt;string&gt; tags, string itemDate, 
          List&lt;IFormFile&gt; documents)
          : this()
      {
          Title = title;
          Description = description;
          Count = count
          Tags = tags;
          ItemDate = itemDate;
          Documents = documents;
      }
  }
  </code></pre>
  
  <p>In Postman I now setup the request as follows:</p>
  
  <p><a href="https://i.stack.imgur.com/wGFV0.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/wGFV0.png" alt="enter image description here"></a></p>
  
  <p>I've had to obfuscate some of the information, but you can see that the primitive types with private setters are not set.</p>
  
  <p><a href="https://i.stack.imgur.com/lKZl2.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/lKZl2.png" alt="enter image description here"></a></p>
  
  <p><strong>Questions</strong></p>
  
  <ol>
  <li>Why does the property access modifier only affect properties with primitive types?</li>
  <li>Why does this happens when the parameter attribute is set to <code>FromForm</code> but not when it's set to <code>FromBody</code></li>
  </ol>