0

I am using AWS SES service to send email to users. Upon registration, a token is generated in my AccountServive.sc

var confirmEmailToken = await _userManager.GenerateEmailConfirmationTokenAsync(user); 

I have a function in this service SendEmailForAccountCreatedAndEmailVerification which takes the username, and link to replace the HTML body for an email. And this body is passed in the EmailSender function.

How to create link from this token that the user receives in his/her mail which can be clicked to confirm is email address?

1 Answer 1

1

The full code for generating activation link already defined under Register.cshtml.cs and RegisterConfirmation.cshtml.cs :

var userId = await _userManager.GetUserIdAsync(user); var code = await _userManager.GenerateEmailConfirmationTokenAsync(user); code = WebEncoders.Base64UrlEncode(Encoding.UTF8.GetBytes(code)); EmailConfirmationUrl = Url.Page( "/Account/ConfirmEmail", pageHandler: null, values: new { area = "Identity", userId = userId, code = code }, protocol: Request.Scheme); 
Sign up to request clarification or add additional context in comments.

4 Comments

I have been trying this and the variations of this. I am consistently getting an error: The name 'Url' does not exist in the current context Similary for Request
I'm not generating link in the controller base, I'm working in the service class where I want to generate the link. That's why, Url.Action won't work
So, the ConfirmEmail is in a different project?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.