title: Can't pass array of data to controller in Asp.NET
body: <p>So I'm trying to pass an array of Ids to the controller of my ASP.NET application to save to the database, but every time I send the data, the arrays show up as empty when passed to the controller. Other data passes through okay but it's just the arrays.</p>
  <p>Any help or recommendations would be greatly appreciated.</p>
  <pre><code>@using (Html.BeginForm(&quot;SaveCoursesFor&quot;, &quot;Courses&quot;))
  {
      for (int i = 0; i &lt; Model.ElectiveCount; i++)
      {
          &lt;div class=&quot;form-group&quot;&gt;
              @Html.Label(&quot;First Choice&quot;)
              @Html.DropDownListFor(c =&gt; c.FirstChoices[i], new SelectList(Model.AvailableCourses, &quot;Id&quot;, &quot;Name&quot;), &quot;Please select a course&quot;, new { @class = &quot;form-control&quot; })
              @Html.ValidationMessageFor(c =&gt; c.FirstChoices[i])
              @Html.Label(&quot;Second Choice&quot;)
              @Html.DropDownListFor(c =&gt; c.SecondChoices[i], new SelectList(Model.AvailableCourses, &quot;Id&quot;, &quot;Name&quot;), &quot;Please select a course&quot;, new { @class = &quot;form-control&quot; })
              @Html.ValidationMessageFor(c =&gt; c.SecondChoices[i])
          &lt;/div&gt;
          &lt;br /&gt;
      }    
      &lt;button type=&quot;submit&quot; class=&quot;btn btn-primary&quot;&gt;Submit&lt;/button&gt;
  }
  </code></pre>
  <p>This is the model that's being passed:</p>
  <pre><code>public class SelectCoursesViewModel
  {
      public List&lt;Course&gt; AvailableCourses { get; set; }
      public int[] FirstChoices;
      public int[] SecondChoices;
      public int ElectiveCount { get; set; }
      public SelectCoursesViewModel()
      {
          FirstChoices = new int[ElectiveCount];
          SecondChoices = new int[ElectiveCount];
      }
  }
  </code></pre>
  <p>This is what shows up on the network tab:
  <a href="https://i.stack.imgur.com/Zj61g.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Zj61g.png" alt="" /></a></p>