In my ASP.NET MVC web app, I have set up password recovery and it all works very well, however the hyperlink will not display correctly.
It prints out the entire url rather than the text I'd like to have eg. "here"
Is this an issue with my code or perhaps just the email.
string code = await UserManager.GeneratePasswordResetTokenAsync(user.Id);
var callbackUrl = Url.Action("ResetPassword", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme);
await UserManager.SendEmailAsync(user.Id, "Holiday Tracker Reset Password", "Please reset your password by using the following link. Copy and paste it into the url. <a href=\"" + callbackUrl + "\">here</a>");
return RedirectToAction("ForgotPasswordConfirmation", "Account");
Sned Email Action:
void sendMail(IdentityMessage message)
{
#region formatter
string text = string.Format("", message.Subject, message.Body);
string html = "";
html += HttpUtility.HtmlEncode(@"" + message.Body);
#endregion
MailMessage msg = new MailMessage();
msg.From = new MailAddress(ConfigurationManager.AppSettings["Email"].ToString());
msg.To.Add(new MailAddress(message.Destination));
msg.Subject = message.Subject;
msg.AlternateViews.Add(AlternateView.CreateAlternateViewFromString(html, null, MediaTypeNames.Text.Html));
msg.AlternateViews.Add(AlternateView.CreateAlternateViewFromString(html, null, MediaTypeNames.Text.Html));
SmtpClient smtpClient = new SmtpClient("smtp-mail.outlook.com", Convert.ToInt32(587));
System.Net.NetworkCredential credentials = new System.Net.NetworkCredential(ConfigurationManager.AppSettings["Email"].ToString(), ConfigurationManager.AppSettings["Password"].ToString());
smtpClient.Credentials = credentials;
smtpClient.EnableSsl = true;
smtpClient.Send(msg);
}
Ideally, I'd like the user not have to paste the link into the url bar but rather be able to click the hyperlink