Hello,
I have two web forms (MemberInvite.aspx and NewTeamSignup.aspx).
In MemberInvite.aspx is where I send registration link to email, while NewTeamSignup.aspx is where the link will be redirected to when user clicks on the link in the mail. But it appears that when the user clicks on the link in the email, the redirection is taken back to MemberInvite.aspx.
Code behind to send link to email (MemberInvite.aspx.cs)
public partial class MemberInvite : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
// Set userId after successfully login.
Session["UserID"] = User;
}
}
protected void Button1_Click(object sender, EventArgs e)
{
using (MailMessage mm = new MailMessage("ukosimons@gmail.com", Emailtxtbx.Text))
{
mm.Subject = "Account Registration.";
string body = "Hello " + Emailtxtbx.Text.Trim() + ",";
body += "<br /><br />Please click the following link to Sign up";
body += "<br /><a href = '" + Request.Url.AbsoluteUri.Replace("Default.aspx", "NewTeamSignup.aspx?Id=" + Session["userID"]) + "'>Click here for Sign up</a>.";
body += "<br /><br />Thanks";
mm.Body = body;
mm.IsBodyHtml = true;
SmtpClient smtp = new SmtpClient();
smtp.Host = "smtp.gmail.com";
smtp.EnableSsl = true;
NetworkCredential NetworkCred = new NetworkCredential("ukosimons@gmail.com", "password");
smtp.UseDefaultCredentials = true;
smtp.Credentials = NetworkCred;
smtp.Port = 587;
smtp.Send(mm);
Div1.Visible = true;
lblsuccess.Visible = true;
lblsuccess.Text = "Registration Link Sent!";
lblsuccess.ForeColor = System.Drawing.Color.Green;
}
}