Click here to Skip to main content
15,891,902 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
i complete sending registraion link ...vie email but it this url share by some one any one can register ..so what can i do for that link can use only once or after some time expire.

What I have tried:

i add funtion of email and my gmail email address and passwork for sending link....
Posted
Updated 17-Apr-16 19:06pm
Comments
Richard Deeming 14-Apr-16 14:15pm    
You need some code on the server to log the fact that the link has been used / is no longer valid, and reject any future requests for that link.

But since we can't see how you're generating the links, it's impossible to guide you any further.
Member 12466752 18-Apr-16 3:34am    
my code \\\email function

public void approve(ContactUsModel objModelMail)
{
var data = (from tbl_con in dbo_obj.tbl_contactus where tbl_con.Id == objModelMail.Id select tbl_con).FirstOrDefault();
data.EmailId = objModelMail.EmailId;
data.status = "Approve";
dbo_obj.SaveChanges();
string from = "ngoportal.jd@gmail.com"; //any valid GMail ID
string to = objModelMail.EmailId;
using (MailMessage mail = new MailMessage(from, to))
{
mail.Subject = "Äpprove Request";
string URL = "http://localhost:61435/NGOPortal/NGORegister";
mail.Body = "Hi  " + objModelMail.Name + ", </br></br>Please find the Registration Link. Click the following URL http://localhost:61435/NGOPortal/NGORegister to Registration for NGO.</br></br>Regards,</br>ADMIN</br>NGO Portal";
mail.IsBodyHtml = true;
SmtpClient smtp = new SmtpClient();
smtp.Host = "smtp.gmail.com";
smtp.EnableSsl = true;
NetworkCredential networkCredential = new NetworkCredential(from,"ngoportal123456");

smtp.UseDefaultCredentials = true;
smtp.Credentials = networkCredential;
smtp.Port = 587;
smtp.Send(mail);
}

}
Member 12466752 18-Apr-16 1:06am    
i am sending my code to you .. curently i am sending link + text ..
but i want to now add guid with link ..so can u guid me how can i do that. i am sending my code to you.

my db field is
name , email , status (approve by default)
and now i add two new field
1> link +guid and 2> status2 (0/1)
if 1 then registratio done now i have to give expriry msg
Richard Deeming 18-Apr-16 8:13am    
Why have you created a new account to post this?

1 solution

The way I do it is to send the link as a "registration completion" page link with a GUID query string. The page looks up the GUID in a DB table and if it exists completes the registration and deletes the GUID entry.
If it doesn't (or it's expired) it rejects the registration.
 
Share this answer
 
Comments
Member 12466752 18-Apr-16 0:56am    
i understand your ans ...but how can i use GUID in my code..can you please guide me

i have field
name
email
status -> approve (bydefuult)
now i have to add two more field
link -> link which i sent every time
status -> boll (0/1)


if registratio complate then it's entry in db 1 and bydefualt i't 0 ..
on 1 entry i give expiry url
OriginalGriff 18-Apr-16 3:07am    
Add a separate table "PendingRegistrations"

Id (GUID)
Expires (DATETIME)
UserID (Whatever your user id is, FOREIGN KEY to users table)

When you load the "registration complete" page from the link you sent, you read back the GUID from the link Query string and check the new table for a value with the right GUID and a non-expired date. If it is, you have the link to the user table.
Once a month, or once a week, you purge the table, and delete expired user registration attempts.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900