单击激活电子邮件链接,重定向到“成功”页面VB.NET

时间:2014-04-25 20:06:12

标签: asp.net vb.net email registration

我创建了一个注册网络表单,将用户重定向到“检查您的电子邮件以完成注册”页面。他们的下一步是检查他们的电子邮件,然后单击电子邮件中提供的链接。到目前为止,一切正常。但是,单击链接时,会再次将其重定向到注册页面。我无法弄清楚如何更改此内容以转到为其指定的页面,其中显示“您的帐户已成功激活。”

Using mm As New MailMessage("****@outlook.com", txtEmailAddress.Text)
        mm.Subject = "Account Activation"
        Dim body As String = "Hello " + txtFirstName.Text.Trim() + ","
        body += "<br /><br />Please click the following link to activate your account"
        body += "<br /><a href = '" + Request.Url.AbsoluteUri.Replace("VB.aspx", Convert.ToString("VB_Activation.aspx?ActivationCode=") & ActivationCode) + "'>Click here to activate your account.</a>"
        body += "<br /><br />Thanks"
        mm.Body = body
        mm.IsBodyHtml = True
        Dim smtp As New SmtpClient()
        smtp.Host = "smtp.live.com"
        smtp.EnableSsl = True
        Dim NetworkCred As New NetworkCredential("****@outlook.com", "****") 
        smtp.UseDefaultCredentials = True
        smtp.Credentials = NetworkCred
        smtp.Port = 587
        Try
            smtp.Send(mm)
        Catch ex As Exception
            MsgBox("Email was not sent")
        End Try
    End Using

2 个答案:

答案 0 :(得分:0)

我相信这一行:

body += "<br /><a href = '" + Request.Url.AbsoluteUri.Replace("VB.aspx", Convert.ToString("VB_Activation.aspx?ActivationCode=") & ActivationCode) + "'>Click here to activate your account.</a>"

必须以某种方式附加到您的网站激活页面。

答案 1 :(得分:0)

在Web应用程序中创建页面VB_Activation.aspx并编写代码以使用发送给它的ActivationCode激活用户。如果该文件已存在,请确保代码中的文件名与您为处理激活用户而创建的文件名相匹配。

另外,您可以更改此行:

    body += "<br /><a href = '" + Request.Url.AbsoluteUri.Replace("VB.aspx", Convert.ToString("VB_Activation.aspx?ActivationCode=") & ActivationCode) + "'>Click here to activate your account.</a>"

    body += "<br /><a href = 'http://www.yoursite.com/VB_Activation.aspx?ActivationCode=" & ActivationCode & "'>Click here to activate your account.</a>"