---
title: "How to get all users in mvc?"  
description: "How to get all users in mvc?"  
author: "Anonymous User"  
published: 2014-10-09  
updated: 2014-10-09  
canonical: https://www.mindstick.com/forum/2348/how-to-get-all-users-in-mvc  
category: "asp.net mvc"  
tags: ["asp.net", "asp.net mvc"]  
reading_time: 1 minute  

---

# How to get all users in mvc?

I’m using the [Membership](https://www.mindstick.com/interview/2228/in-which-database-is-the-information-such-as-membership-role-management-profile-and-web-parts-personalization-stored) [Provider](https://answers.mindstick.com/qa/92701/who-is-the-best-telecom-solution-provider) and would like to display a list of all the users and their First Name, Last Name etc using the GetAllUsers [function](https://www.mindstick.com/articles/13001/multi-statement-table-valued-user-defined-function-in-sql-server).\
I'm [having trouble](https://answers.mindstick.com/qa/50524/how-to-fix-iphone-8-that-s-overheating-and-having-trouble-turning-on) [understanding](https://www.mindstick.com/articles/12918/cat-5e-vs-cat-6a-understanding-the-major-differences) how to implement this function in MVC.\
Has [anyone](https://www.mindstick.com/articles/23207/how-to-find-the-best-fit-job-for-anyone) implemented this in MVC or is there an easier way to list all the users in my [application](https://www.mindstick.com/articles/12824/calculator-application-in-android)?Any help or advise would be really helpful.**[Controller](https://www.mindstick.com/blog/273/passing-values-from-controller-to-view-in-asp-dot-net-mvc):**

```
public ActionResult GetUsers()        {            var users = Membership.GetAllUsers();            return View(users);        }
```

******[View Model](https://www.mindstick.com/forum/160237/explain-razor-view-model-binding-how-does-it-work-and-why-is-it-important):******

```
public class GetUsers        {            [Required]            [DisplayName("User name")]            public string UserName { get; set; }             [Required]            [DisplayName("User name")]            public string FirstName { get; set; }        }
```

******View:******

```
<%= Html.Encode(item.UserName) %>
```

```
Error:
```

## Replies

### Reply by Anonymous User

try this:

\

**View:**

**\**\

Inherits="System.Web.Mvc.ViewPage<MembershipUserCollection>"

```
<ul>       <%foreach (MembershipUser user in
Model){ %>        <li><%=user.UserName %></li>        <% }%></ul>
```

**Controller:\**

```
public ActionResult Admin()        {            var users = Membership.GetAllUsers();            return View(users);        }
```


---

Original Source: https://www.mindstick.com/forum/2348/how-to-get-all-users-in-mvc

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
