Asp.net 用户ID的电子邮件验证问题
我正在尝试使用asp.net中的创建用户向导根据本文www.4guysfromrolla.com/articles/062508-1.aspx创建新帐户,禁用了他的帐户以便立即登录,并在注册后立即发送电子邮件到相关电子邮件进行验证,一切正常 对不起,伙计们,没有min rep我无法上传图片,所以我现在只能提供2个链接 现在的问题是发送给用户的电子邮件中包含了url USERID: 下面是如何将其添加到数据库中,如图所示: 现在,在Asp.Net配置中,当用户被禁用时,显示如下: 如上图所示,用户名旁边没有勾选标记,这意味着用户已被禁用,他需要使用电子邮件验证激活他的帐户 因此,当用户单击click时,它会告诉我在数据库中找不到该用户 我真的被这件事难倒了,网络上的每一个人都给我看了同一篇发送电子邮件的文章。但没有一个成功 还是我做错了什么?我想让你们中的一些人了解我 以下是我创建用户和发送电子邮件的代码:Asp.net 用户ID的电子邮件验证问题,asp.net,createuserwizard,custom-membershipprovider,email-verification,Asp.net,Createuserwizard,Custom Membershipprovider,Email Verification,我正在尝试使用asp.net中的创建用户向导根据本文www.4guysfromrolla.com/articles/062508-1.aspx创建新帐户,禁用了他的帐户以便立即登录,并在注册后立即发送电子邮件到相关电子邮件进行验证,一切正常 对不起,伙计们,没有min rep我无法上传图片,所以我现在只能提供2个链接 现在的问题是发送给用户的电子邮件中包含了url USERID: 下面是如何将其添加到数据库中,如图所示: 现在,在Asp.Net配置中,当用户被禁用时,显示如下: 如上图所示,用户
Protected Sub CreateUserWizard1_SendingMail(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.MailMessageEventArgs) Handles CreateUserWizard1.SendingMail
Dim newUserAccount As MembershipUser = Membership.GetUser(CreateUserWizard1.UserName)
Dim newUserAccountId As Guid = DirectCast(newUserAccount.ProviderUserKey, Guid)
Dim domainName As String = Request.Url.GetLeftPart(UriPartial.Authority) + Request.ApplicationPath
Dim confirmationPage As String = "EmailConfirmation.aspx?UserID=" & newUserAccountId.ToString()
Dim url As String = domainName & confirmationPage
e.Message.Body = e.Message.Body.Replace("<%VerificationUrl%>", url)
Dim smtp As New SmtpClient()
smtp.Host = "smtp.gmail.com"
smtp.Port = 587
smtp.UseDefaultCredentials = False
smtp.Credentials = New System.Net.NetworkCredential("myemail@gmail.com", "gmailpassword")
smtp.EnableSsl = True
smtp.Send(e.Message)
e.Cancel = True
End Sub
这是对我有效的解决方案
Dim ConString As String = ConfigurationManager.ConnectionStrings("HDIConnectionString").ConnectionString
Dim UserID As String
Dim i As Integer = 0
If (Request.QueryString("UserID") IsNot Nothing) Then
UserID = Request.QueryString("UserID")
Dim con As New SqlConnection(ConString)
Dim cmd As New SqlCommand("UPDATE Users SET IsApproved=1 WHERE UserID=@UserID ", con)
cmd.Parameters.AddWithValue("@UserID", UserID)
con.Open()
i = cmd.ExecuteNonQuery()
con.Close()
End If
If i > 0 Then
lblMessage.Text = "Your account has been approved. Please <a href=""Login.aspx"">login</a> to the site."
Else
lblMessage.Text = "User account could not be found..."
End If
Dim ConString As String = ConfigurationManager.ConnectionStrings("HDIConnectionString").ConnectionString
Dim UserID As String
Dim i As Integer = 0
If (Request.QueryString("UserID") IsNot Nothing) Then
UserID = Request.QueryString("UserID")
Dim con As New SqlConnection(ConString)
Dim cmd As New SqlCommand("UPDATE Users SET IsApproved=1 WHERE UserID=@UserID ", con)
cmd.Parameters.AddWithValue("@UserID", UserID)
con.Open()
i = cmd.ExecuteNonQuery()
con.Close()
End If
If i > 0 Then
lblMessage.Text = "Your account has been approved. Please <a href=""Login.aspx"">login</a> to the site."
Else
lblMessage.Text = "User account could not be found..."
End If