如何在我的注册链接中添加guid查询字符串 [英] How can I add guid querystring in my registration link

查看:155
本文介绍了如何在我的注册链接中添加guid查询字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前我的链接是



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



但我想添加guid所以此链接不使用超过1次..如何在我的链接中添加guid?



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







和注册后相同的链接不能用于新的注册..我发送我的代码belove



我尝试过:



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:

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);
            }

        }

推荐答案

你好,



我从来没有用过这个,但是在很少的搜索中,我发现它是可能的。请按照以下链接。



Hello,

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

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









在路由中使用GUID约束:

asp.net mvc - 怎么能我创建了System.Guid类型的路由约束? [ ^ ]



查询字符串中的GUID

c# - 重写包含GUID的URl Asp.net MVC Razor中的查询字符串 [ ^ ]



我希望这些链接可以帮助您理解。

谢谢





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


这篇关于如何在我的注册链接中添加guid查询字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆