Click here to Skip to main content
15,897,704 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
currenly my link goes as

"http://localhost:61435/NGOPortal/NGORegister";

but i want to add guid so this link is not use more then 1 time.. how can i add guid in my link ??

"http://localhost:61435/NGOPortal/a2cc5900-bdff-41f1-9c2a-21032a5275de";



and after registration same link can not be use for new regisration ..i am sending my code belove

What I have tried:

C#
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 + ", Please find the Registration Link. Click the following URL <a href="" + URL + "">http://localhost:61435/NGOPortal/NGORegister</a>  to Registration for NGO.Regards,ADMINNGO 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);
            }

        }
Posted
Updated 17-Apr-16 19:46pm
v2
Comments
Richard Deeming 18-Apr-16 8:12am    
REPOST
Why have you created a new account to repost your question?
http://www.codeproject.com/Questions/1092503/One-time-link-no-more[^]

1 solution

Hello,

I have never used this, but on few searches, I found it to be possible. Please follow the below links.

C#
routes.MapRoute(name: "AnyName",
url: "/{controller}/{Action}/{paramName}",
defaults: new { controller = "User", action = "Login" },
constraints: {paramName= new GuidConstraint() }
);   




Using GUID constraints in routing:
asp.net mvc - How can I create a route constraint of type System.Guid?[^]

GUID in Query string
c# - Rewriting URl containg GUID as query string in Asp.net MVC Razor[^]

I hope these links will help you understand.
Thanks
 
Share this answer
 
v2

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