Why isn't UserId more readily available #23300
Unanswered
SoftCircuits
asked this question in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
If I need the current user name, I can use
User.Identity.Name
. No problem.However, if I need to save a reference to this user, the user name can change. Better to store the ID instead. But I'm surprised to find that
User.Identity.Id
is not a thing.In fact, my research so far suggests the ID is not available unless I get an instance of
UserManager
, or query the database.It seems that the user ID is at least as useful as the user name. What is the preferred way to obtain it? And why isn't it more readily available?
Beta Was this translation helpful? Give feedback.
All reactions