Asp.net core genrate confirm email link
At registration, asp.net core produces the correct URL to acknowledge the callback email link, but it is not clickable. However, please copy the link and paste it into the address bar, which will work fine. How to make that link clickable?
ASP.NET Core
-
AgaveJoe • 29,361 Reputation points
2023-05-03T10:55:08.44+00:00 It sounds like you did not create a standard HTML link in the email body. Unfortunately, this is only a guess since you did not share the code that creates the email.
-
Agha Khan • 166 Reputation points
2023-05-03T16:52:39.2966667+00:00 Thanks for the reply. I tried all options. Here is the code
string message = $"Please confirm your account by <a href='{HtmlEncoder.Default.Encode(callbackUrl)}'>clicking</a> here."; await _emailSender.SendEmailAsync(Input.Email, "Confirm your email", message );
-
AgaveJoe • 29,361 Reputation points
2023-05-03T17:34:36.6366667+00:00 I tried all options.
Clearly, you have not tried all options since the rest of the world can send a link in an Email. You must understand that we cannot debug two lines of code through this forum.
Does the email have a link and the link is wrong or does the mail display the anchor tag? Did you configure the Email body as HTML content? Lastly, what is the value of HtmlEncoder.Default.Encode(callbackUrl) and callbackUrl? Is HtmlEncoder.Default.Encode(callbackUrl) and callbackUrl correct????
-
Agha Khan • 166 Reputation points
2023-05-03T18:47:32.0533333+00:00 Thank you for your reply. The code I am using belongs to Microsoft. To make my point, I created an asp.net core application with no code of mine. Kindly look .\Areas\Identity\Pages\Account\Register.cshtml.cs line 128. This code produces the correct URL but not a clickable link.
-
Agha Khan • 166 Reputation points
2023-05-03T19:01:04.7366667+00:00 Thank you for your reply.
To make my point, I have created a test application. I did not modify any code, and all code belongs to Microsoft. This application will produce a non-clickable link. You may look at .\Areas\Identity\Pages\Account\Register.cshtml.cs line 127
-
Agha Khan • 166 Reputation points
2023-05-03T19:15:33.4833333+00:00 You might not have a service for sending emails, so you might be unable to debug due to email service. I just provided the code.
-
AgaveJoe • 29,361 Reputation points
2023-05-03T19:20:11.49+00:00 This code produces the correct URL but not a clickable link.
Okay, so now we know you scaffolded Identity and verified the URL is correct.
To make my point, I have created a test application. I did not modify any code, and all code belongs to Microsoft.
That's not true! You had to implement IEmailSender as an Email client does not come with the template. Did you enable HTML in the Email body? Can you share the implementation?
-
Agha Khan • 166 Reputation points
2023-05-03T19:27:04.3166667+00:00 You will find another application in the same link, and an email service is provided.
-
Agha Khan • 166 Reputation points
2023-05-05T02:59:27.97+00:00 Today I looked at the link in a text editor and found out there is protection by Outlook. You can only open that link if the tour website is secure https://. The link must come from the website where the security certificate is installed. This is a guess, and I might need to be corrected.
-
AgaveJoe • 29,361 Reputation points
2023-05-05T10:46:40.9366667+00:00 What is the URL?
-
Agha Khan • 166 Reputation points
2023-05-05T18:07:47.6566667+00:00 It is a test site and it will not work. The actual website which is secure is www.RealCrimeToday.com and I will update today if I will able to finish login functionality. The test website is www.surprisinggames.com. Thanks for asking and replying.
-
AgaveJoe • 29,361 Reputation points
2023-05-05T18:16:35.1366667+00:00 For the third time, what is the URL? Is the site's certificate valid?
-
Agha Khan • 166 Reputation points
2023-05-05T18:23:46.9033333+00:00 Did I not answer your question? The test website (www.surprisinggames.com) does not have a valid certificate and I think that is the problem. I will update that functionality (www.RealCrimeToday.com with a valid certificate) today and let you know the result.
-
Agha Khan • 166 Reputation points
2023-05-06T07:49:42.07+00:00 Bring that file from the junk folder to the inbox folder, and the link will work fine. I thought maybe not having a valid certificate was the problem, but I was wrong. It is working fine.
Sign in to comment