'Hello I am hoping to send a link to a user who has forgotten his password. The page is online here: www.dimadayoub.net/forgot.aspx The code I am using (which is followed by SMTP), is as follows: Code: Protected Sub btnForgot_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnForgot.Click Const ConnectionString As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|students.mdb;" Dim uniqueCode As String = Guid.NewGuid().ToString("N") Dim recordExists As Boolean = False 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", strEmailTextBox.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() I take it that the 'uniqueCode' is the link? If so, where does it come from, please? It is normally a link that the user clicks on and is taken to a password reset page ('resetPwd.aspx' in my case), but what generates the link? Thank you. Steve
No, "builder" is your link. "uniqueCode" is a randomly generated id/text to make sure no 2 links are the same. According to the code, it's the query string (parameter) of the Url/Uri that is being sent.