title: Why model binding with a struct doesn't work?
body: <p>I'm trying to understand why this binding doesn't work.<br>
  The binding didn't work until I changed the type from <code>struct</code> to <code>class</code>.<br>
  Is this by design or am I missing something?</p>
  
  <p>I'm using asp.net core 2.2 MVC</p>
  
  <p><strong>View Models</strong></p>
  
  <p><em>Not working</em></p>
  
  <pre><code>public class SettingsUpdateModel
  {
      public DeviceSettingsStruct DeviceSettings  { get; set; }
  }
  </code></pre>
  
  <p><em>Working</em></p>
  
  <pre><code>public class SettingsUpdateModel
  {
      public DeviceSettingsClass DeviceSettings  { get; set; }
  }
  </code></pre>
  
  <pre><code>public class DeviceSettingsClass
  {
      public bool OutOfScheduleAlert { get; set; }
  // other fields removed for brevity
  }
  
  public struct DeviceSettingsStruct
  {
      public bool OutOfScheduleAlert { get; set; }
  // other fields removed for brevity
  }
  </code></pre>
  
  <p><strong>Controller</strong></p>
  
  <pre><code>[HttpPost]
  public IActionResult Update(SettingsUpdateModel newSettings)
  {
      // newSettings.DeviceSettings.OutOfScheduleAlert always false on struct but correct on class
      return Index(null);
  }
  </code></pre>
  
  <p><strong>View</strong></p>
  
  <pre><code>&lt;input class="form-check-input" type="checkbox" id="out_of_schedule_checkbox" asp-for="DeviceSettings.OutOfScheduleAlert"&gt;
  </code></pre>
  
  <p>Expected: <code>DeviceSettings.OutOfScheduleAlert</code> to bind to a struct the same as class
  Actual: only the class parameter was binded</p>