title: GetAllUsers - MVC
body: <p>I’m using the Membership Provider and would like to display a list of all the users and their First Name, Last Name etc using the <code>GetAllUsers</code> function.</p>
  
  <p>I'm having trouble understanding how to implement this function in MVC.</p>
  
  <p>Has anyone implemented this in MVC or is there an easier way to list all the users in my application?</p>
  
  <p>Any help or advise would be really helpful.</p>
  
  <p><strong>Controller</strong></p>
  
  <pre><code>public ActionResult GetUsers()
  {
      var users = Membership.GetAllUsers();
      return View(users);
  }
  </code></pre>
  
  <p><strong>View Model</strong></p>
  
  <pre><code>public class GetUsers
      {
          [Required]
          [DisplayName("User name")]
          public string UserName { get; set; }
  
          [Required]
          [DisplayName("User name")]
          public string FirstName { get; set; }
      }
  </code></pre>
  
  <p><strong>View</strong></p>
  
  <pre><code>&lt;%= Html.Encode(item.UserName) %&gt;
  </code></pre>
  
  <p><strong>Error</strong></p>
  
  <p>The model item passed into the dictionary is of type 'System.Web.Security.MembershipUserCollection', but this dictionary requires a model item of type 'System.Collections.Generic.IEnumerable`1[Account.Models.GetUsers]'.</p>