title: post multi-select list to list of objects asp.net core 2
body: <p>I have two classes called <code>User</code> and <code>Role</code>.</p>
  <pre><code>class User
  {
      ...
      public List&lt;Role&gt; Roles;
  }
  
  class Role
  {
      ...
      public int ID;
      public string Name;
  }
  </code></pre>
  <p>I also have an action (Submit)</p>
  <pre><code>public IActionResult Submit(User user)
  {
      ...
  } 
  </code></pre>
  <p>in my Index.cshtml <code>select</code> is</p>
  <pre><code>&lt;select multiple=&quot;multiple&quot; class=&quot;multi-select&quot; id=&quot;my_multi_select1&quot; asp-for=&quot;Roles&quot; asp-items=&quot;ViewBag.Roles&quot;&gt;&lt;/select&gt; 
  </code></pre>
  <p>and <code>ViewBag.Roles</code> value is</p>
  <pre><code>ViewBag.Roles= new SelectList(Role.SelectAll(), &quot;Name&quot;, &quot;Name&quot;);
  </code></pre>
  <p>the problem is that when I post my form, data is sent like this
  <code>...&amp;Roles=role1,role2&amp;...</code>
  and so <code>user.Roles</code> becomes null while I want to make two Roles with names <code>role1</code> and <code>role2</code> and assign them to <code>user.Roles</code> (Actually, I want Asp does that)</p>