asp.net - 我如何知道新生成的密码

标签 asp.net

尝试实现asp.net密码恢复控件。

我想在发送给用户之前捕获新生成的密码并向其添加一些自定义逻辑,然后发送邮件。只有一个事件发送邮件事件。

我怎样才能捕获它?

最佳答案

您可以处理 SendingMail 事件,使用 ResetPassword 生成新密码,然后使用新密码以及您想要在其中输入的任何内容更新电子邮件正文。

protected void PasswordRecovery1_SendingMail(object sender, MailMessageEventArgs e)
{
    // grab the user.
    MembershipUser mu = Membership.GetUser(PasswordRecovery1.UserName);

    if (mu != null)
    {

        // reset the password.
        string newPass = mu.ResetPassword();

        // switch out the body of the email.
        e.Message.Body = string.Format("New Password: {0}\n", newPass);

    }

}

关于asp.net - 我如何知道新生成的密码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/539157/

相关文章:

javascript - 应用程序/代码安全

c# - ASP.NET MVC - 整个模型的显示名称

c# - WebRequest.GetResponse() 抛出错误 401 : Unauthorized

asp.net - 某些浏览器上的 AjaxPro 中的 ConnectFailure

asp.net - 关于使用 ASP.net WebForms 或 MVC 的建议

.net - 如何编写像 Google 或 Yahoo 一样轻量级的 Web 部件

asp.net - MVC3 中用户权限/ session 变量的最佳实践

c# - 为什么我会收到此错误 : The ConnectionString property has not been initialized

c# - 如何通过电子邮件发送的链接登录到 asp.net 应用程序

asp.net - 将超链接应用于图像