I'm having a problem with trying to get the Password Recovery to work properly or maybe it's that I'm doing something completely wrong. I have a Masterpage which contains a Login Control in the header along with Password Recovery set to "Forgot Password"
and the Password Recovery URL set to ~/ForgotPassword.aspx. In the code-behind of my Masterpage I get the User's username from the Username textbox and store it in a Session variable.Then on my ForgotPassword.aspx page I grab the username from the Session
variable and try to use it in my PasswordRecovery_SendingMail method. A couple of problems here, first my PasswordRecovery_SendingMail method is never reached I set a break-point, but it never hits it for sending the email. If I move my code to send the email
into the Page_Load and set a break-point it will hit it there.
The other problem is in my web.config file I have the following settings.
My understanding was that if the passwordFormat is set to Hashed that a new password is emailed to the user who is requesting it be reset. However it's not working.
I finally figuered it out, but I still have a problem. According to the settings I have in my web.config file and what I read the password should be reset. When I go through a reset process, I get the message "Your password has been sent to you", but it
doesn't contain any password in the email.
Dim smtp As New System.Net.Mail.SmtpClient()
Dim smail As New System.Net.Mail.MailMessage
smail.To.Add(New System.Net.Mail.MailAddress("emailtowhomyouwanttosend@yahoo.com "))
smail.From = New System.Net.Mail.MailAddress("youremail@gmail.com", "Visit me")
smail.Subject = "hiii"
smail.IsBodyHtml = "true"
smail.Body = "HELLO THERE"
smtp.EnableSsl = True
smtp.Send(smail)
CB40
Member
2 Points
17 Posts
Password Recovery Guideance
Dec 03, 2008 11:03 PM|LINK
Hi,
I'm having a problem with trying to get the Password Recovery to work properly or maybe it's that I'm doing something completely wrong. I have a Masterpage which contains a Login Control in the header along with Password Recovery set to "Forgot Password" and the Password Recovery URL set to ~/ForgotPassword.aspx. In the code-behind of my Masterpage I get the User's username from the Username textbox and store it in a Session variable.Then on my ForgotPassword.aspx page I grab the username from the Session variable and try to use it in my PasswordRecovery_SendingMail method. A couple of problems here, first my PasswordRecovery_SendingMail method is never reached I set a break-point, but it never hits it for sending the email. If I move my code to send the email into the Page_Load and set a break-point it will hit it there.
The other problem is in my web.config file I have the following settings.
<membership defaultProvider="MyMembershipProvider"> <providers> <add name="MyMembershipProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="LocalSqlServer" applicationName="MyApp" requiresQuestionAndAnswer="false" minRequiredPasswordLength="7" minRequiredNonalphanumericCharacters="1" requiresUniqueEmail="true" maxInvalidPasswordAttemps="3" passwordAttempWindow="5" enablePasswordRetrieval="false" enablePasswordReset="true" passwordFormat="Hashed" /> </providers> </membership>exuviae
Participant
1167 Points
221 Posts
Re: Password Recovery Guideance
Dec 03, 2008 11:56 PM|LINK
You need a mail settings config section in your web.config:
There are other parameters you can set, but that is the basics.
<system.net> <mailSettings> <smtp from="info@123.com"> <network host="smtp.123.com" password="" userName=""/> </smtp> </mailSettings> </system.net>Chris Dupuy
http://techblog.chrisdupuy.com
CB40
Member
2 Points
17 Posts
Re: Password Recovery Guideance
Dec 04, 2008 12:02 AM|LINK
Thanks, but I've already tried that and actually I'm sending the email from code.
guru_sarkar
All-Star
22198 Points
3463 Posts
Re: Password Recovery Guideance
Dec 04, 2008 04:59 PM|LINK
Try Setting MailDefinition Property of PasswordRecovery Control
Or please share any other code / info... you think will help us to understand the problem
CB40
Member
2 Points
17 Posts
Re: Password Recovery Guideance
Dec 05, 2008 03:47 AM|LINK
I finally figuered it out, but I still have a problem. According to the settings I have in my web.config file and what I read the password should be reset. When I go through a reset process, I get the message "Your password has been sent to you", but it doesn't contain any password in the email.
What am I missing?
yasserzaid
Star
13991 Points
2597 Posts
Re: Password Recovery Guideance
Dec 05, 2008 10:44 AM|LINK
Hi
try this in web.config
just change connection string name with your's
<membership defaultProvider="MyProvider" userIsOnlineTimeWindow="25">
<providers>
<add name="MyProvider" type="System.Web.Security.SqlMembershipProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" connectionStringName="eLocalize_ConnStr" applicationName="/" enablePasswordRetrieval="true" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" passwordFormat="Clear" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="5" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" passwordStrengthRegularExpression=""/>
</providers>
</membership>
<roleManager cacheRolesInCookie="true" cookieName="TaskCookie" cookiePath="/" cookieProtection="None" cookieRequireSSL="true" cookieSlidingExpiration="false " cookieTimeout="60" defaultProvider="TaskRoleProvider" enabled="true">
<providers>
<add name="TaskRoleProvider" connectionStringName="eLocalize_ConnStr" applicationName="/" type="System.Web.Security.SqlRoleProvider"/>
</providers>
</roleManager>
but if you want to send email try this:
copy the following code.. its working for my gmail account
in web.config
<system.net>
<mailSettings>
<smtp from="youremail@gmail.com">
<network host="smtp.gmail.com" port="587" userName="youremail" password="xx" defaultCredentials="false"/>
</smtp>
</mailSettings>
</system.net>
In code behind ( on button click)
Dim smtp As New System.Net.Mail.SmtpClient()
Dim smail As New System.Net.Mail.MailMessage
smail.To.Add(New System.Net.Mail.MailAddress("emailtowhomyouwanttosend@yahoo.com "))
smail.From = New System.Net.Mail.MailAddress("youremail@gmail.com", "Visit me")
smail.Subject = "hiii"
smail.IsBodyHtml = "true"
smail.Body = "HELLO THERE"
smtp.EnableSsl = True
smtp.Send(smail)
It will work for sure..
Good Luck
or check this post
http://forums.asp.net/t/1337021.aspx
CB40
Member
2 Points
17 Posts
Re: Password Recovery Guideance
Dec 05, 2008 11:15 AM|LINK
Won't this send the password in clear text? If so I don't want the user's password to be sent that way, because it's not secure. Is there another way?
yasserzaid
Star
13991 Points
2597 Posts
Re: Password Recovery Guideance
Dec 05, 2008 03:17 PM|LINK
Hi
check this link
http://mishler.net/PermaLink,guid,ea65afc0-2970-46f1-9412-4b57bbd906f4.aspx
Good Luck