Pregunta

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.

¿Fue útil?

Solución

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.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top