0
我有一個超鏈接在一個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="bedofr[email protected]" 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內部構建時,才能進入最後一步,並且不會發送電子郵件。但是,用戶無法登錄他/她的用戶名和舊密碼。