Reputation: 31237
We can get a logged in user by configuring the UserManager with the ApplicationUser
So far so good for getting logged in user data!
Problem:
Is there a way to get user(s) who are not logged in?
Maybe by some alternative for User.Identity.GetUserId()
method - which works for logged in users?
By passing user number or username or so?
Aim: This is needed for different situations such as:
Upvotes: 1
Views: 643
Reputation: 2982
If you are using Identity 2.0+ then it exposes an IQueryable interface to the user store. You can use this to do almost everyhting you asked about:
UserManager.Users.Where(w => w.Location == "Mars").ToList();
You can use any kind of LINQ fanciness there. You may also just hit the DB table directly as you do in other controllers. If using EF, something like:
db.AspNetUsers.Where(w => w.Username == "Bob").AsEnumerable();
Upvotes: 2