使用电子邮件而不是用户名恢复密码
我宁愿让他们输入电子邮件地址并重置密码并将其发送给他们,而不是强迫用户记住用户名。
我在会员提供程序下使用 ASP .Net PasswordRecovery 控件。
现在系统工作正常,它重置密码并发送给用户。 然而,我发现许多用户忘记了他们的用户名。 显然,我在发给他们的电子邮件中包含了用户名。
理想情况下,我会完全放弃用户名,但不幸的是我已经有用户的用户名不是电子邮件地址。
那么,如何轻松更改我的PasswordRecovery 控件以询问用户的电子邮件地址并将重置密码和用户名发送到该地址?
我尝试添加
UserNameLabelText="Email:" OnVerifyingUser="PasswordRecovery1_VerifyingUser"
到 asp:PasswordRecovery 和
protected void PasswordRecovery1_VerifyingUser(
object sender
, MailMessageEventArgs e)
{ PasswordRecovery1.UserName =
System.Web.Security.Membership.GetUserNameByEmai(PasswordRecovery1.UserName); }
关联的 .cs 文件中,但控件无法编译并出现错误
CS0123:“PasswordRecovery1_VerifyingUser”匹配没有重载 委托“System.Web.UI.WebControls.LoginCancelEventHandler”
我不明白的
Rather than forcing users to remember a UserName, I would rather have them enter their email address and have the password reset and sent to them.
I am using ASP .Net PasswordRecovery control under the membership provider.
Right now the system works fine, it resets the password and sends to the user. However, I find that many users forget their UserName. Obviously, I include the UserName in the email to them.
Ideally, I would dispense with usernames completely, but unfortunately I already have users with UserNames that are not email addresses.
So, how can I easily change my PasswordRecovery control to ask for the user's email address and send the reset password, and UserName to that address?
I tried adding
UserNameLabelText="Email:" OnVerifyingUser="PasswordRecovery1_VerifyingUser"
to the asp:PasswordRecovery, and
protected void PasswordRecovery1_VerifyingUser(
object sender
, MailMessageEventArgs e)
{ PasswordRecovery1.UserName =
System.Web.Security.Membership.GetUserNameByEmai(PasswordRecovery1.UserName); }
in the associated .cs file, but the control fails to compile with an error
CS0123: No overload for 'PasswordRecovery1_VerifyingUser' matches
delegate 'System.Web.UI.WebControls.LoginCancelEventHandler'
which I do not understand
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以实现PasswordRecovery.VerifyingUser 事件的处理程序以允许用户提供用户名或密码。
You can implement a handler of the PasswordRecovery.VerifyingUser event to allow the user to provide either a user name or a password.
因此,如果用户不知道他们的用户名,他们会提供他们的电子邮件,然后您使用 FindUsersByEmail 或 GetUsernameByEmail。
如果他们不知道自己的电子邮件地址,他们会提供用户名,然后您使用 FindUsersByName。
正如凯德指出的那样 - 从你的帖子中你的问题并不是很明显。
So if the user doesn't know their username, they provide their email and you use FindUsersByEmail or GetUsernameByEmail.
If they don't know their email address, they provide their username and you use FindUsersByName.
As Cade pointed out - your question isn't really obvious from your post.