I tried some codes but after it is send to mail account, it is always the active how can it become passive link .
string UName = GetNewValidationCode();
// Now lets create an email message
SmtpClient SmtpServer = new SmtpClient("smtp.live.com");
var mail = new MailMessage();
mail.From = new MailAddress("bilkentliaslan@windowslive.com");
mail.To.Add(TextBox6.Text);
mail.Subject = "Registration";
mail.IsBodyHtml = true;
string htmlBody;
htmlBody = string.Format("Thank you for creating an account with YourDomain.com</ br>"+"Please click the below link to activate your account <br />"+"<a href='http://localhost:2386/ActivateUser.aspx?userName{0}&Id={1}'>Activate {0} </a>", UName, user_name);
mail.Body = htmlBody;
SmtpServer.Port = 587;
SmtpServer.UseDefaultCredentials = false;
SmtpServer.Credentials = new System.Net.NetworkCredential("bilkentliaslan@windowslive.com", "my password");
SmtpServer.EnableSsl = true;
SmtpServer.Send(mail);
// Redirecto to What ever page
Response.Redirect("Login.aspx");
Keep a table that stores the waiting IDs, i.e., the IDs that you have sent an email about, but which are not yet activated.
Then in the code of your
ActivateUser.aspx(actually in the back-end code that that page then calls), check if the row exists, perform the user activation work and then remove the row from the table. If the user then goes to the very same URL again later, the row won’t be there and the user won’t be (re-)activated.