Mike Marks
Mike Marks

Reputation: 10139

Trying to access the ASPNETDB.MDF database file to get user information.. ASP.NET MVC

Hey everyone... I'm trying to access user information that's contained within the ASPNETDB.MDF file. I'm using ASP.NET MVC. This file gets created when you launch the ASP.NET Configuration tool from Visual Studio. So, I create users, roles, etc. via this ASP.NET Configuration tool, and the data gets saved to this database file.

I'm needing to gain access to user information (just the user name) to use within my application. For example, what I'm trying to do is populate a drop down list with a list of user names (which were created from the ASP.NET Configuration tool, and therefore reside within this ASPNETDB database file). I think if I can figure out how to get that information then I can figure out the rest.

Is there any other way someone would suggest me going about this? I could create a separate users table in my main database, but I would rather use the one in the ASPNETDB database that's already created, just so I use one source for my user's information and not two.

Upvotes: 0

Views: 2684

Answers (1)

Shekhar_Pro
Shekhar_Pro

Reputation: 18430

You can use Membership.GetUser() method to get all users in the database as a MembershipUser. You can also use following LINQ Query to get a list of user names

 var users = from user in Membership.GetUsers() 
                 orderby user.UserName 
                 select user.UserName

Upvotes: 1

Related Questions