post multi-select list to list of objects asp.net core 2
问题 I have two classes called User and Role. User is like this class User{ ... public List<Role> Roles; } and Role is like this class Role{ ... public int ID; public string Name; } now I have an action (Submit) public IActionResult Submit(User user){ ... } in my index.cshtml select is <select multiple="multiple" class="multi-select" id="my_multi_select1" asp-for="Roles" asp-items="ViewBag.Roles"></select> and ViewBag.Roles value is ViewBag.Roles= new SelectList(Role.SelectAll(), "Name", "Name");