title: Post List<Model> from form in MVC
body: <p>I have a need to be able to post back an unknown number of this model class:</p>
  
  <pre><code>public class UserRegisterModel
  {
      public string UserName { get; set; }
  
      public string Password { get; set; }
  
      public string ConfirmPassword { get; set; }
  
      public string RepName { get; set; }
  
      public string ContactNumber { get; set; }
  }
  </code></pre>
  
  <p>in a <code>List&lt;UserRegisterModel&gt;</code> to a controller.</p>
  
  <p>I need my view to have a form that can send back multiple instances of the model to the controller, so for example if my user wants to add 3 Reps, he can make 3 reps and give them each details and usernames and passwords, and send them all back at once in a List.</p>
  
  <p>I have this starting point for my view code: </p>
  
  <pre><code>@model List&lt;PicsWebApp.Models.UserRegisterModel&gt;
  
  @{
      ViewBag.Title = "NewRep";
  }
  
  &lt;h2&gt;NewRep&lt;/h2&gt;
  
  @using (Html.BeginForm("NewRep", "Admin", FormMethod.Post, new { id = "fieldform", @class = "form" }))
  {
  }
  </code></pre>
  
  <p>Can anybody show me the correct way of accomplishing this? I know I need javascript in order to dynamically add more form elements if the user clicks "add new rep" so this is mainly about the C#.</p>