Reputation: 325
I am trying to recover the value of the user who is logged on the site but I am currently blocked.
I use .Net core 2.1 with EF Core. I created a context called jakformulaireContext
and also jakformulaireUser
.
I have to send an email to confirm that a user has registered to an event but I can not find the piece of code allowing me to recover the field "email" which is in the database.
In the scaffolding part which contains the Register controller I succeeded because I would recover the value of the field "email" but here I am in a controller that is located outside of Account.
So I tried to do a find but it does not seem to be the right method because I get a Task <> while I just want a string.
var user = _userManager.FindByEmailAsync ("[email protected]");
Would you have a solution?
Upvotes: 1
Views: 127
Reputation: 4673
If you have an async method it will return a Task. So what you need to do is wait until that method is finished. The way to do it is:
var user = await _userManager.FindByEmailAsync ("[email protected]");
More information about async/wait
Upvotes: 2