Find
in EF uses the argument as the key value. I don't think the Name property is the key property and therefore you always get null.
How to get the current user with Signalr?
-
22-07-2023 - |
سؤال
I tried this, but the user always ends up being null:
ApplicationDbContext db = new Models.ApplicationDbContext();
var user = db.Users.Find(Context.User.Identity.Name);
if (user == null)
{
caller.displayMessage("Error: User does not exist.");
return;
}
So, how do I get the current user? I need to get the user's Id and email address.
المحلول
لا تنتمي إلى StackOverflow