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 内にビルドされている場合のみ、最後のステップに進むことができず、メールが送信されませんでした。ユーザー名と古いパスワードを使用しても、ユーザーはログインできませんでした。