密码恢复未发送电子邮件



我有一个超链接,它是在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中构建时,它才能继续到最后一步,并且没有发送电子邮件。然而,当用户的用户名和旧密码时,用户无法登录

最可能的原因可能是当您的表单在Model Popup中打开时,表单(即密码恢复表单)不再保留在form标记中。所以你需要做一些类似的事情

jQuery(function() {
   var dlg = jQuery("#dialog").dialog({ 
                        draggable: true, 
                        resizable: true, 
                        show: 'Transfer', 
                        hide: 'Transfer', 
                        width: 320, 
                        autoOpen: false, 
                        minHeight: 10, 
                        minwidth: 10 
          });
  dlg.parent().appendTo(jQuery("form:first"));
});

它正在移动FORM DOM中的Popup。当您的表单不在FORMDOM中时,它的数据将不会被发布回服务器。

参考:带有ASP.NET按钮的jQuery UI对话框回发

最新更新