views:

425

answers:

2

Hello,

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?

Thanks you.

+2  A: 

What is your question?

Cade Roux
You are right, I really never did get to the question. Edited.
Degan
+1  A: 

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.

Chuck
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.GetUserNameByEmail(PasswordRecovery1.UserName); } in the associated .cs file, but the control failes to compile with an error CS0123: No overload for 'PasswordRecovery1_VerifyingUser' matches delegate 'System.Web.UI.WebControls.LoginCancelEventHandler' which loses me.
Degan
PasswordRecovery1_VerifyingUser should have a second parameter of type System.Web.UI.WebControls.LoginCancelEventArgs: http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.passwordrecovery.onverifyinguser.aspx not of type MailMessageEventArgs. You'll also want to check that the username does indeed match a email address pattern, otherwise GetUsernameByEmail will return null and empty out the UserName field.
Zhaph - Ben Duguid
Thank you, Zhaph, I really had no thought that I was sending the wrong parameter type. It is working now.
Degan