title: ASP.NET Core how to pass List<int> from view to Controller
body: <p>In ASP.NET Core, I have searched around but cannot figure out how to pass a list from the view to controller. I can create a <code>form</code> and pass a single <code>int</code> value, but not a <code>List&lt;int&gt;</code>.Here is what I have to pass a single value</p>
  <pre><code>&lt;form id=&quot;myForm&quot;&gt;
      &lt;div class=&quot;modal-body&quot;&gt;
          &lt;div class=&quot;form-group&quot;&gt;
             &lt;label class=&quot;custom-label&quot;&gt;
             &lt;div class=&quot;col-sm-3&quot;&gt;
                 &lt;input name=&quot;singleValue&quot; type=&quot;text&quot; class=&quot;form-control&quot; /&gt;
             &lt;/div&gt;
          &lt;/div&gt;
          &lt;a href=&quot;#&quot; class=&quot;btn btn-success&quot; onclick=&quot;SaveForm('UpdateFunction', 'ControllerName')&quot;&gt;Update&lt;/a&gt;
  &lt;/form&gt;
  </code></pre>
  <p>My controller is</p>
  <pre><code>public IActionResult UpdateFunction(int singleValue)
  {
      var model = _context.TableName.SingleOrDefault(f =&gt; f.Id == singleValue);
      model.Name = &quot;Whatever&quot;;
      _context.Update(model);
      _context.SaveChanges();
  
      return Json(true);
  }
  </code></pre>
  <p>However because I would like to update multiple values at a time instead of just <code>int singleValue</code>, I have tried passing</p>
  <p><code>public IActionResult UpdateFunction(int[] list)</code> or
  <code>public IActionResult UpdateFunction(List&lt;int&gt; list)</code></p>
  <p>into the function parameters. I have tried entering multiple <code>int</code> values into the text box with/without commas, brackets, nothing works and the lists are always empty. My goal is to just pass the list or array to controller, then loop through the values in the list. My question is how can I pass a <code>List&lt;int&gt;</code> to the controller?</p>