如何在第一次单击后禁用电子邮件链接 [英] How to disable an email link after first click

查看:89
本文介绍了如何在第一次单击后禁用电子邮件链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我在电子邮件中发送一个带有查询字符串的链接来重置密码。当用户点击链接时,这个重定向到我的网站resetPwd.aspx上的用户,他/她可以在数据库中成功重置密码。

再次如果用户试图打开电子邮件中的链接,则强制要求它不允许用户打开该链接。如何在第二次点击时阻止

电子邮件链接?





我的C#代码



Hi,
I am sending a link in the email with query string to reset password. When user click on link this redirect to user on my website resetPwd.aspx and he/she can reset password successfully in database.
Again if the user is trying to open the link in email, its compulsory that it cant allow the user to open that link. How to block
the email link in the second click?


My C# code

private void sendEmail(string emailTo, string userId)
{
    string UserName = LoginUser.UserName;
    using (StreamReader reader = File.OpenText(Server.MapPath("~/App_Data/ResetPwdEmailBody.txt")))
    {
        string urlBase = Request.Url.GetLeftPart(UriPartial.Authority) + Request.ApplicationPath;
        string verifyUrl = "/Account/UnlockAccount.aspx?uName=" + UserName + "&id=" + userId;
        string fullUrl = urlBase + verifyUrl;
        MailMessage msg = new MailMessage();
        msg.Subject = "Unlock your account";
        msg.IsBodyHtml = true;
        msg.To.Add(new MailAddress(emailTo, UserName));
        msg.Body = reader.ReadToEnd();
        msg.Body = msg.Body.Replace("<%resetPassword%>", fullUrl);
        msg.Body = msg.Body.Replace("<% UserName %>", UserName);
        msg.Priority = MailPriority.High;
        SmtpClient myClient = new SmtpClient();
        myClient.EnableSsl = false;
        try
        {
            myClient.Send(msg);
        }
        catch (Exception ex)
        {
            LoginUser.FailureText = "Email cannot be send. Error: " + ex.Message;
        }
    }

}







提前致谢,



Ashok Luhach




Thanks in advance,

Ashok Luhach

推荐答案

试试这个链接:





仅在asp.net中发送重置密码链接一次使用









如果他们帮助您找到解决方案,请不要忘记将有用的回复标记为答案。
Try this link:


Sending reset password link for one time use only in asp.net




Don''t forget to mark useful responses as Answer if they helped you towards a solution.


这篇关于如何在第一次单击后禁用电子邮件链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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