C# 中的密码恢复工具不起作用

发布于 2024-08-09 05:30:21 字数 3764 浏览 9 评论 0原文

嗨(我对此很陌生),

我创建了一个门户,用户可以在其中登录,他们可以在其中查看我制作的其他程序。问题是密码恢复似乎不起作用 - 我没有收到任何错误消息,我只是收到消息“我们无法访问您的信息。请重试。” 我正确设置了 ASP.NET 配置,并使用不同的用户和权限对其进行了测试,但我只是想知道是否需要在配置管理器或 web.config 中执行某些操作才能使其正常工作。

以下是密码恢复工具的代码:

<form id="form1" runat="server">
<div align="center">
    <asp:PasswordRecovery ID="PasswordRecovery1" runat="server" Height="147px" Width="442px" BackColor="#F7F6F3" BorderColor="#E6E2D8" BorderPadding="4" BorderStyle="Solid" BorderWidth="1px" Font-Names="Verdana" Font-Size="0.8em">
        <UserNameTemplate>
            <table border="0" cellpadding="1" cellspacing="0" style="border-collapse: collapse">
                <tr>
                    <td style="width: 445px">
                        <table border="0" cellpadding="0" style="width: 442px; height: 147px">
                            <tr>
                                <td align="center" colspan="2">
                                    <strong><span style="font-size: 0.9em">Password Recovery</span></strong></td>
                            </tr>
                            <tr>
                                <td align="center" colspan="2">
                                    &nbsp;</td>
                            </tr>
                            <tr>
                                <td align="right">
                                    <asp:Label ID="UserNameLabel" runat="server" AssociatedControlID="UserName">Username:</asp:Label></td>
                                <td style="width: 291px">
                                    <asp:TextBox ID="UserName" runat="server" Width="187px"></asp:TextBox>
                                    <asp:RequiredFieldValidator ID="UserNameRequired" runat="server" ControlToValidate="UserName"
                                        ErrorMessage="User Name is required." ToolTip="User Name is required." ValidationGroup="PasswordRecovery1">*</asp:RequiredFieldValidator>
                                </td>
                            </tr>
                            <tr>
                                <td align="center" colspan="2" style="color: red">
                                    <asp:Literal ID="FailureText" runat="server" EnableViewState="False"></asp:Literal>
                                </td>
                            </tr>
                            <tr>
                                <td align="right" colspan="2" style="text-align: right">
                                    <asp:Button ID="SubmitButton" runat="server" CommandName="Submit" Text="Submit" ValidationGroup="PasswordRecovery1"
                                        Width="103px" />
                                    &nbsp; &nbsp;
                                </td>
                            </tr>
                        </table>
                    </td>
                </tr>
            </table>
        </UserNameTemplate>
        <InstructionTextStyle Font-Italic="True" ForeColor="Black" />
        <SuccessTextStyle Font-Bold="True" ForeColor="#5D7B9D" />
        <TextBoxStyle Font-Size="0.8em" />
        <TitleTextStyle BackColor="#5D7B9D" Font-Bold="True" Font-Size="0.9em" ForeColor="White" />
        <SubmitButtonStyle BackColor="#FFFBFF" BorderColor="#CCCCCC" BorderStyle="Solid"
            BorderWidth="1px" Font-Names="Verdana" Font-Size="0.8em" ForeColor="#284775" />
    </asp:PasswordRecovery>
</div>
</form>

谢谢。

Hi (I'm pretty new to this),

I have created a portal where the user logs in and within that, they can view other programs I've made. The problem is the password recovery does not seem to be working - I get no error messages, I just get the message "We were unable to access your information. Please try again."
I have the ASP.NET configuration setup correctly and have tested this with different users and permissions but I was just wondering if there is something I need to do in the configuartion manager or the web.config so that this can work.

Below is the code for the password recovery tool:

<form id="form1" runat="server">
<div align="center">
    <asp:PasswordRecovery ID="PasswordRecovery1" runat="server" Height="147px" Width="442px" BackColor="#F7F6F3" BorderColor="#E6E2D8" BorderPadding="4" BorderStyle="Solid" BorderWidth="1px" Font-Names="Verdana" Font-Size="0.8em">
        <UserNameTemplate>
            <table border="0" cellpadding="1" cellspacing="0" style="border-collapse: collapse">
                <tr>
                    <td style="width: 445px">
                        <table border="0" cellpadding="0" style="width: 442px; height: 147px">
                            <tr>
                                <td align="center" colspan="2">
                                    <strong><span style="font-size: 0.9em">Password Recovery</span></strong></td>
                            </tr>
                            <tr>
                                <td align="center" colspan="2">
                                     </td>
                            </tr>
                            <tr>
                                <td align="right">
                                    <asp:Label ID="UserNameLabel" runat="server" AssociatedControlID="UserName">Username:</asp:Label></td>
                                <td style="width: 291px">
                                    <asp:TextBox ID="UserName" runat="server" Width="187px"></asp:TextBox>
                                    <asp:RequiredFieldValidator ID="UserNameRequired" runat="server" ControlToValidate="UserName"
                                        ErrorMessage="User Name is required." ToolTip="User Name is required." ValidationGroup="PasswordRecovery1">*</asp:RequiredFieldValidator>
                                </td>
                            </tr>
                            <tr>
                                <td align="center" colspan="2" style="color: red">
                                    <asp:Literal ID="FailureText" runat="server" EnableViewState="False"></asp:Literal>
                                </td>
                            </tr>
                            <tr>
                                <td align="right" colspan="2" style="text-align: right">
                                    <asp:Button ID="SubmitButton" runat="server" CommandName="Submit" Text="Submit" ValidationGroup="PasswordRecovery1"
                                        Width="103px" />
                                       
                                </td>
                            </tr>
                        </table>
                    </td>
                </tr>
            </table>
        </UserNameTemplate>
        <InstructionTextStyle Font-Italic="True" ForeColor="Black" />
        <SuccessTextStyle Font-Bold="True" ForeColor="#5D7B9D" />
        <TextBoxStyle Font-Size="0.8em" />
        <TitleTextStyle BackColor="#5D7B9D" Font-Bold="True" Font-Size="0.9em" ForeColor="White" />
        <SubmitButtonStyle BackColor="#FFFBFF" BorderColor="#CCCCCC" BorderStyle="Solid"
            BorderWidth="1px" Font-Names="Verdana" Font-Size="0.8em" ForeColor="#284775" />
    </asp:PasswordRecovery>
</div>
</form>

Thank you.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

关于从前 2024-08-16 05:30:21

如果您的一位用户收到此错误(“我们无法访问您的信息。请重试”)(但其他用户工作正常),很可能只是帐户被锁定。

要解锁帐户,请运行存储过程:[aspnetdb].[dbo].[aspnet_Membership_UnlockUser]

您需要传入应用程序名称和要解锁的用户名。

如果您不知道应用程序名称,可以从 [aspnetdb].[dbo].[aspnet_Applications] 表中进行检查。

If you get this error ("We were unable to access your information. Please try again") for one user (but other users work fine), most likely it's just the account is locked.

To unlock the account run the stored procedure: [aspnetdb].[dbo].[aspnet_Membership_UnlockUser]

You need to pass in your application name, and the username to unlock.

If you don't know your application name, you can check from the [aspnetdb].[dbo].[aspnet_Applications] table.

涙—继续流 2024-08-16 05:30:21

对我来说看起来不错。
检查您的 webconfig 以确保您的会员资格提供商已

  • enablePasswordRetrieval =“ false”
  • enablePasswordReset =“ true”
  • 需要QuestionAndAnswer =“ false”

此外,您还需要在web.config中设置邮件定义,以便控件能够邮寄新密码。

<mailSettings>
  <smtp from="[email protected]">
    <network host="your.smtp.server" port="25"/>
  </smtp>
</mailSettings>

Looks right to me.
Check your webconfig to make sure your membership provider has

  • enablePasswordRetrieval="false"
  • enablePasswordReset="true"
  • requiresQuestionAndAnswer="false"

Also you need to set up a mail definition in your web.config for the control to be able to mail the new password.

<mailSettings>
  <smtp from="[email protected]">
    <network host="your.smtp.server" port="25"/>
  </smtp>
</mailSettings>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文