我有一个在 LoginView 内构建的超链接,文本设置为“忘记密码”。
单击超链接后,将弹出密码恢复控件(使用 AJAX ModalPopUp 扩展器的实现)。modalpopup 运行良好。但问题是,在输入用户名后,在步骤 2 中用户回答了他/她的安全答案后,当点击“提交”按钮时,它不会进入步骤 3,也没有发送电子邮件。
但是,数据库中的密码已更改(我尝试使用用户名和旧密码登录,但没有成功)。
这是 passwordrecover.aspx 的代码:
<asp:HyperLink ID="HyperLink2" runat="server"
style="margin-top:15px; text-align: right;">Forget Password</asp:HyperLink>
<asp:ModalPopupExtender
ID="HyperLink2_ModalPopupExtender"
runat="server"
BackgroundCssClass="modalBackground"
DynamicServicePath=""
Enabled="True"
PopupControlID="Panel1"
TargetControlID="HyperLink2" >
</asp:ModalPopupExtender>
<asp:Panel ID="Panel1"
runat="server"
BackColor="White"
BorderColor="Black"
BorderStyle="Solid"
BorderWidth="2px"
Height="200px"
Width="360px">
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:PasswordRecovery ID="PasswordRecovery1" runat="server"
onsendingmail="PasswordRecovery1_SendingMail">
<MailDefinition BodyFileName="~/EmailTemplates/ResetPassword.htm"
From="bedofrosesptltd@gmail.com" IsBodyHtml="True" Priority="High"
Subject="Request on the password reset for BedOfRoses's account.">
</MailDefinition>
</asp:PasswordRecovery>
</ContentTemplate>
</asp:UpdatePanel>
<asp:Button ID="btnClose" runat="server" Text="Close" />
</asp:Panel>
这是后面的代码:
protected void PasswordRecovery1_SendingMail(object sender, MailMessageEventArgs e)
{
System.Web.UI.WebControls.PasswordRecovery PasswordRecovery1 = (System.Web.UI.WebControls.PasswordRecovery)LoginView1.FindControl("PasswordRecovery1");
MembershipUser pwRecover = Membership.GetUser(PasswordRecovery1.UserName);
Guid userInfoId2 = (Guid)pwRecover.ProviderUserKey;
//Create an url that will link to a UserProfile.aspx and
//accept a query string that is the user's id
//setup the base of the url
string domainName = Request.Url.GetLeftPart(UriPartial.Authority) + Request.ApplicationPath;
//setup the second half of the url
string confirmationPage = "/Members/UserProfile.aspx?ID=" + userInfoId2.ToString();
//combine to make the final url
string url = domainName + confirmationPage;
// Replace <%VerifyUrl%> placeholder with url value
e.Message.Body = e.Message.Body.Replace("<%ResetPassword%>", url);
}
- 如果我从 ModalPopUp 中删除密码恢复控件,整个控件将完美运行。只有当它在 ModalPopUp 中构建时,它才能进行最后一步并且没有发送电子邮件。然而,当他/她的用户名和旧密码时,用户无法登录。