Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Often, a user is required to type i

Status
Not open for further replies.

Blueie

Technical User
May 12, 2012
72
GB
Often, a user is required to type in his email address in the case of a forgotten password. A message is sent to that address with a link for the user to click on in order to reset his password. I have something like this:

Code:
Using conn As New OleDbConnection(ConnectionString)
            Using cmd As OleDbCommand = conn.CreateCommand()
                cmd.CommandText = "UPDATE university SET uniqueCode = @uniqueCode WHERE strEmail = @strEmail"
                cmd.Parameters.AddWithValue("@uniqueCode", uniqueCode)
                cmd.Parameters.AddWithValue("@strEmail", strEmail.Text.Trim())

                conn.Open()
                Dim recordsAffected As Integer = cmd.ExecuteNonQuery()
                If recordsAffected <> 0 Then recordExists = True
            End Using
        End Using

        If recordExists Then

            Dim builder As New UriBuilder(Request.Url)
            builder.Path = VirtualPathUtility.ToAbsolute("~/resetPwd.aspx")
            builder.Query = "uniqueCode=" & HttpUtility.UrlEncode(uniqueCode)

            Dim link As String = builder.Uri.ToString()

            ' Eg: [URL unfurl="true"]http://localhost:2464/SampleApplication/ResetPasswordVB.aspx?uniqueCode=ee3106b4df694555b4ca6f2727a23dc8[/URL]

SMTP code here

How is that link generated, please? How would I begin to code it?

Thanks.
 
I don't understand your question. What is it that you want to do? Is this your code, or are you modifying existing code?
 
The stringbuilder is building the string.. which is the URL for the link using the VirtualPathUtility
From what I see of your code, it is doing what it is supposed to do. So, what exactly is the problem/question?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top