If I'm trying to send an email immediately a new email has been confirmed, how to I go about it ?
The piece of code below is what I have in ConfirmEmail
method. When I run the code, I get Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
on await UserManager.SendEmailAsync(userId, "API", "API Code is: " + user.ApiCode);
I think UserManager.FindById
is not returning anything, but not sure how to go about it.
Any pointers/ideas will help.
public async Task<ActionResult> ConfirmEmail(string userId, string code)
{
if (userId == null || code == null)
{
return View("Error");
}
var result = await UserManager.ConfirmEmailAsync(userId, code);
var user = UserManager.FindById(User.Identity.GetUserId());
await UserManager.SendEmailAsync(userId, "API", "API Code is: " + user.ApiCode);
return View(result.Succeeded ? "ConfirmEmail" : "Error");
}