【问题标题】:asp.net confirmation mail send link that contains a unique identifier包含唯一标识符的 asp.net 确认邮件发送链接
【发布时间】:2012-01-07 12:00:31
【问题描述】:

我想发送一个包含唯一标识符的链接并在另一个名为 login.aspx 的页面中验证 Guid

那么如何添加链接以及如何从 login.aspx 中检索 Guid 以将其与我保存在 SQL 数据库中的那个进行比较...

这是代码

    Sub emailConfirm()
    Dim email As String = txtMail.Text
    Dim nom As String = txtPrenom.Text + txtNom.Text
    Dim pass As String = txtPass.Text
    Dim user As String = txtUserName.Text
    Dim mail As MailMessage = New MailMessage()
    Dim sGUID As String
    sGUID = System.Guid.NewGuid.ToString()
    (I will put the guid in the Sql DB) 
    mail.To.Add(email)
    mail.From = New MailAddress("superman@gmail.com")
    mail.Subject = "Email Comfirmation de nouvel utilisateur"

    Dim Body As String = "Hi " + nom + ", this mail is to confirm your registration" + "Click on    the link to confirm your membership please"+"href="login.aspx?ID="& sGUID"(This is not work...)
    mail.Body = Body

    mail.IsBodyHtml = True
    Dim smtp As SmtpClient = New SmtpClient()
    smtp.Host = "smtp.gmail.com"
    smtp.Port = 587
    smtp.Credentials = New System.Net.NetworkCredential("superman@gmail.com", "1234")
    smtp.EnableSsl = True
    smtp.Send(mail)


End Sub

感谢您的帮助!!!

它在 Vb.net 中

【问题讨论】:

  • vb.net-informations.com/dataset/dataset-sqlserver.htm 我会选择 "SELECT [GUID] FROM [TABLE] WHERE [GUID] = '" + sGUID + "'"; style 语句,以及一个简单的 if /else 语句进行比较。
  • "href="login.aspx?ID="& sGUID"(这不起作用...)我想将我的 guid 添加到邮件正文的链接中...问题1以及问题 2 如何从 aspx.login 中检索 Guid......

标签: asp.net vb.net


【解决方案1】:

第 1 步: 您需要将完整的 url 放在 href 中,而不仅仅是 login.aspx。
示例:“href="http://nameofmywebsite.com/login.aspx?ID="& sGUID"

第 2 步 在登录页面上,您将从上面的 href 中传递的查询字符串中检索 GUID。 示例:

request.querystring.get("sGUID")

希望这会有所帮助。

【讨论】:

  • 如果它在本地虚拟服务器上,我该怎么做?我在 Visual Studio 或 Web 矩阵中运行它...我没有域名...
  • 您可以使用 Request.Url.Authority 构建完整的 url,这也适用于虚拟服务器。
猜你喜欢
  • 1970-01-01
  • 2014-02-08
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-09-07
  • 1970-01-01
  • 2016-05-10
  • 2019-11-28
相关资源
最近更新 更多