gpt4 book ai didi

c# - 使用 Request.Url.AbsoluteUri.Replace 重定向

转载 作者:太空宇宙 更新时间:2023-11-03 12:28:32 25 4
gpt4 key购买 nike

我想在我的网站上注册后向用户发送验证邮件。注册页面是位于 root/login/的 Signup.aspx。

我可以成功地向包含链接的用户发送邮件,代码如下

protected void SendActivationEmail()
{

string activationCode = Guid.NewGuid().ToString();

using (MailMessage mm = new MailMessage("registration@estoreproj.xyz", tbEmail.Text))
{
mm.Subject = "Account Activation";
string body = "Hello " + tbUname.Text + ",";
body += "<br /><br />Please click the following link to activate your account";
body += "<br /><a href = '" + Request.Url.AbsoluteUri.Replace("Signup.aspx", "estoreproj.xyz/login/CS_Activation.aspx?ActivationCode=" + activationCode) + "'>Click here to activate your account.</a>";
body += "<br /><br />Thanks";
mm.Body = body;
mm.IsBodyHtml = true;
SmtpClient smtp = new SmtpClient();
smtp.Host = "estoreproj.xyz";
smtp.EnableSsl = false;
NetworkCredential NetworkCred = new NetworkCredential("registration@estoreproj.xyz", "mypassword");
smtp.UseDefaultCredentials = true;
smtp.Credentials = NetworkCred;
smtp.Port = 587;
smtp.Send(mm);
}
}

但是当用户点击链接时它不会重新编辑。注意:网站是 www.estoreproj.xyz

当用户单击链接时,它应该重定向到位于 root/login/的名为 cs_Activation.aspx 的页面

但是用户点击的链接是这样的

https://cs_activation.apsx/?ActivationCode=some random code/login/Signup.aspx

请帮忙?如果标题错了,我不知道如何装帧,对不起

最佳答案

如果知道要a标签去estoreproj.xyz/login/cs_activation.aspx/?ActivationCode=som‌ e随机码

那么最简单的事情就是将 href 设置为那个。所以改变这一行

body += "<br /><a href = '" + Request.Url.AbsoluteUri.Replace("Signup.aspx", "estoreproj.xyz/login/CS_Activation.aspx?ActivationCode=" + activationCode) + "'>Click here to activate your account.</a>";

成为

 body += "<br /><a href = 'https://estoreproj.xyz/login/cs_activation.aspx/?ActivationCode=som‌​e random code'>Click here to activate your account.</a>";

这可能是确定链接指向什么的最简单方法。

关于c# - 使用 Request.Url.AbsoluteUri.Replace 重定向,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43663803/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com