Search code examples
asp.net-mvcasp.net-mvc-5asp.net-identity

List of registered users with details on MVC 5


I would like to know if possible how to get a list of registered users and their details in MVC 5?

I'm sort of trying to get all users outputted to a tabular form just like when creating controllers and views for other data sets where they can be edited and so forth. I'm using ASP .Net Identity to store all user details.


Solution

  • try the following:

    1. Right-click Controllers and Add a new Controller
    2. Choose MVC 5 Controller with views, using Entity Framework
    3. Choose your User object as the Model class (typically this is called ApplicationUser if the project was created from a standard VS/MVC template)
    4. You'll probably find (as I just did) that the scaffolding then adds a new DbSet to your DbContext called ApplicationUsers. You can delete this because I imagine your context should already include a set of users simply called Users.
    5. Finally find and replace ApplicationUsers property with Users in your new controller.

    You should now be able to run your app and navigate to /ApplicationUsers to see a list of all the users, with the usual Edit/Details/Delete action links.