I implemented the PasswordRecovery control and it is working but my question is that my control is sending new password to user that is fine but how can i mail the password change link to the user, so that he can set his new password own his own by clicking
on that link??
Also how can i send the cumstomize mail to user when he request for password recovery??
Here is my code..
PasswordRecovery.aspx
<%@ Page Title="Password Recovery" Language="C#" MasterPageFile="~/site.master" AutoEventWireup="true" CodeFile="PasswordRecovery.aspx.cs" Inherits="Account_PasswordRecovery" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" Runat="Server">
<SCRIPT runat="server">
// Set the field label background color if the user name is not found.
void PasswordRecovery1_UserLookupError(object sender, System.EventArgs e)
{
PasswordRecovery1.LabelStyle.ForeColor = System.Drawing.Color.Red;
}
// Reset the field label background color.
void PasswordRecovery1_Load(object sender, System.EventArgs e)
{
PasswordRecovery1.LabelStyle.ForeColor = System.Drawing.Color.Black;
}
</SCRIPT>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" Runat="Server">
<asp:PasswordRecovery id="PasswordRecovery1" runat="server" BorderStyle="Solid" BorderWidth="1px" BackColor="#F7F7DE"
Font-Size="10pt" Font-Names="Verdana" BorderColor="#CCCC99" HelpPageText="Need help?" HelpPageUrl=recoveryHelp.aspx onuserlookuperror="PasswordRecovery1_UserLookupError" onload="PasswordRecovery1_Load" >
<successtemplate>
<table border="0" style="font-size:10pt;">
<tr>
<td>Your password has been sent to you.</td>
</tr>
</table>
</successtemplate>
<titletextstyle font-bold="True" forecolor="White" backcolor="#6B696B">
</titletextstyle>
</asp:PasswordRecovery>
</asp:Content>
here is PasswordRecovery.aspx.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Net.Mail;
public partial class Account_PasswordRecovery : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
var client = new SmtpClient();
client.EnableSsl = true;
}
protected void PasswordRecovery1_SendingMail(object sender, System.EventArgs e)
{
MailDefinition md = new MailDefinition();
md.BodyFileName = "PasswordRecovery.txt";
md.IsBodyHtml = true;
}
}
Here is template for customize email:
Your password has been reset, <%UserName%>!
According to our records, you have requested that your password be reset. Your new
password is: <%Password%>
If you have any questions or trouble logging on please contact a site administrator.
Thank you!
befor sending email to the user. you can store one key (type Guid) in the database user table and append that key in the password reset url which you will send to the user.
One user clicks on the link and come to your site with the key in the url. you can verify that key from your database and prompt user to reset the password. Url will look like this.
nikunj2512
Member
11 Points
14 Posts
Help with passwordrecovery control
Jun 02, 2012 06:05 PM|LINK
Hi,
I implemented the PasswordRecovery control and it is working but my question is that my control is sending new password to user that is fine but how can i mail the password change link to the user, so that he can set his new password own his own by clicking on that link??
Also how can i send the cumstomize mail to user when he request for password recovery??
Here is my code..
PasswordRecovery.aspx
<%@ Page Title="Password Recovery" Language="C#" MasterPageFile="~/site.master" AutoEventWireup="true" CodeFile="PasswordRecovery.aspx.cs" Inherits="Account_PasswordRecovery" %> <asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" Runat="Server"> <SCRIPT runat="server"> // Set the field label background color if the user name is not found. void PasswordRecovery1_UserLookupError(object sender, System.EventArgs e) { PasswordRecovery1.LabelStyle.ForeColor = System.Drawing.Color.Red; } // Reset the field label background color. void PasswordRecovery1_Load(object sender, System.EventArgs e) { PasswordRecovery1.LabelStyle.ForeColor = System.Drawing.Color.Black; } </SCRIPT> </asp:Content> <asp:Content ID="Content2" ContentPlaceHolderID="MainContent" Runat="Server"> <asp:PasswordRecovery id="PasswordRecovery1" runat="server" BorderStyle="Solid" BorderWidth="1px" BackColor="#F7F7DE" Font-Size="10pt" Font-Names="Verdana" BorderColor="#CCCC99" HelpPageText="Need help?" HelpPageUrl=recoveryHelp.aspx onuserlookuperror="PasswordRecovery1_UserLookupError" onload="PasswordRecovery1_Load" > <successtemplate> <table border="0" style="font-size:10pt;"> <tr> <td>Your password has been sent to you.</td> </tr> </table> </successtemplate> <titletextstyle font-bold="True" forecolor="White" backcolor="#6B696B"> </titletextstyle> </asp:PasswordRecovery> </asp:Content>here is PasswordRecovery.aspx.cs
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Net.Mail; public partial class Account_PasswordRecovery : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { var client = new SmtpClient(); client.EnableSsl = true; } protected void PasswordRecovery1_SendingMail(object sender, System.EventArgs e) { MailDefinition md = new MailDefinition(); md.BodyFileName = "PasswordRecovery.txt"; md.IsBodyHtml = true; } }Here is template for customize email:
Ramesh Chand...
Star
12922 Points
2672 Posts
Re: Help with passwordrecovery control
Jun 02, 2012 07:03 PM|LINK
Hi,
befor sending email to the user. you can store one key (type Guid) in the database user table and append that key in the password reset url which you will send to the user.
One user clicks on the link and come to your site with the key in the url. you can verify that key from your database and prompt user to reset the password. Url will look like this.
Regards
Ramesh