尝试实现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/