Get the user id of a username identity 2.0

BTI-Doug

MVC 5 with asp.net identity 2.0

I understand how to get the currently logged in user id. I have a need to get the user id of a different user in the system. How is this done?

Ex. I need to get the user id of user names "fsmith" ...

Shashi Jeevan M. P.

Inside the AccountController you can call the following method to get user object and then get the User Id.

var user = await UserManager.FindByNameAsync(userName);
var userId = user.Id;

If you are not inside AccountController you can get the UserManager reference using the following code

var UserManager = HttpContext.GetOwinContext().GetUserManager<ApplicationUserManager>();

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How to get user attributes (username, email, etc.) using cognito identity id

From Dev

Instagram get user ID from username

From Dev

get user id from username - buddyPress

From Dev

How to get user Id from username in facebook

From Dev

join user id from tblB to user from tblA and get username

From Dev

ASP.NET Identity2 - How to get User Id with AllowAnonymous Controller?

From Dev

C# Identity UserManager CreateAsync then FindByEmailAsync returns User with Id=0

From Dev

User ID to Username tweepy

From Dev

User ID or Username

From Dev

LINQ Check exist Username then get that User's ID

From Dev

Getting username based profile in laravel & sentry 2 instead of user id

From Java

Get current user id in ASP.NET Identity 2.0

From Dev

Get username from ID

From Dev

Identity 2.0 Get Rolename and UserName by Linq

From Dev

Get Facebook app-scoped user id from global Facebook id, or username

From Dev

WSO2 identity server email as username

From Dev

Get a user by username and password with Laravel

From Dev

Get a User Object by username field

From Dev

Get Full Username of Logged In User

From Dev

Get a User Object by username field

From Dev

android get facebook username and id

From Dev

command to get username via id

From Dev

cakephp instead of user_id how do I get for instance username in the view

From Dev

How can I get username or id of currently logged in user in UWP App

From Java

Getting cognito user pool username from cognito identity pool identityId

From Dev

How to allow user to register with duplicate UserName using Identity Framework 1.0

From Dev

Allow user to log in with either Email OR UserName (AspNet.Identity)

From Dev

Unable to retrieve the user identity (userName and password)from mysql to login

From Dev

get_current_user_id() returning Zero 0

Related Related

  1. 1

    How to get user attributes (username, email, etc.) using cognito identity id

  2. 2

    Instagram get user ID from username

  3. 3

    get user id from username - buddyPress

  4. 4

    How to get user Id from username in facebook

  5. 5

    join user id from tblB to user from tblA and get username

  6. 6

    ASP.NET Identity2 - How to get User Id with AllowAnonymous Controller?

  7. 7

    C# Identity UserManager CreateAsync then FindByEmailAsync returns User with Id=0

  8. 8

    User ID to Username tweepy

  9. 9

    User ID or Username

  10. 10

    LINQ Check exist Username then get that User's ID

  11. 11

    Getting username based profile in laravel & sentry 2 instead of user id

  12. 12

    Get current user id in ASP.NET Identity 2.0

  13. 13

    Get username from ID

  14. 14

    Identity 2.0 Get Rolename and UserName by Linq

  15. 15

    Get Facebook app-scoped user id from global Facebook id, or username

  16. 16

    WSO2 identity server email as username

  17. 17

    Get a user by username and password with Laravel

  18. 18

    Get a User Object by username field

  19. 19

    Get Full Username of Logged In User

  20. 20

    Get a User Object by username field

  21. 21

    android get facebook username and id

  22. 22

    command to get username via id

  23. 23

    cakephp instead of user_id how do I get for instance username in the view

  24. 24

    How can I get username or id of currently logged in user in UWP App

  25. 25

    Getting cognito user pool username from cognito identity pool identityId

  26. 26

    How to allow user to register with duplicate UserName using Identity Framework 1.0

  27. 27

    Allow user to log in with either Email OR UserName (AspNet.Identity)

  28. 28

    Unable to retrieve the user identity (userName and password)from mysql to login

  29. 29

    get_current_user_id() returning Zero 0

HotTag

Archive