ASP 密码恢复不起作用

发布于 2024-09-06 16:41:15 字数 1494 浏览 6 评论 0原文

我的页面上有一个 ASP 密码恢复模块,代码如下所示:

<asp:PasswordRecovery ID="PasswordRecovery1" runat="server">
    <MailDefinition From="[email]">
    </MailDefinition>
</asp:PasswordRecovery>

但是,当我提交表单时,我只是收到消息,“我们无法访问您的信息。请重试。” >

我看到这个问题并确保将这些属性添加到我的web.config 此处:

<providers>
    <remove name="CustomizedMembershipProvider"/>
    <add name="CustomizedMembershipProvider"
        type="System.Web.Security.SqlMembershipProvider"
        connectionStringName="MessageBank"
        applicationName="MessageBank"
        minRequiredPasswordLength="6"
        minRequiredNonalphanumericCharacters="0"
        requiresQuestionAndAnswer="false"
        enablePasswordReset="true"
        enablePasswordRetrieval="false" />
</providers>

电子邮件工作正常,因为该应用程序全天定期发送电子邮件。但由于某种原因,它没有发送恢复电子邮件。

这是相关的 web.config 部分:

<mailSettings>
    <smtp from="[email]">
        <network host="[host]" password="[password]" userName="[username]"/>
    </smtp>
</mailSettings>

更新:我添加了一个函数来处理“SendingMail”事件:

Protected Sub PasswordRecovery_submit(ByVal sender As Object, ByVal e As WebControls.MailMessageEventArgs) Handles PasswordRecovery.SendingMail

我在此函数中添加了一个断点,但它从未到达,上面的错误消息只是出现在应用程序中。还有其他方法可以调试出现的问题吗?

I have an ASP PasswordRecovery module on a page, the code comes up like this:

<asp:PasswordRecovery ID="PasswordRecovery1" runat="server">
    <MailDefinition From="[email]">
    </MailDefinition>
</asp:PasswordRecovery>

However, when I submit the form I just get the message, "We were unable to access your information. Please try again."

I saw this question and made sure to add those attributes to my web.config here:

<providers>
    <remove name="CustomizedMembershipProvider"/>
    <add name="CustomizedMembershipProvider"
        type="System.Web.Security.SqlMembershipProvider"
        connectionStringName="MessageBank"
        applicationName="MessageBank"
        minRequiredPasswordLength="6"
        minRequiredNonalphanumericCharacters="0"
        requiresQuestionAndAnswer="false"
        enablePasswordReset="true"
        enablePasswordRetrieval="false" />
</providers>

The email is working fine because the app sends emails regularly throughout the day. But it's not sending recovery emails for some reason.

Here's the relevant web.config section:

<mailSettings>
    <smtp from="[email]">
        <network host="[host]" password="[password]" userName="[username]"/>
    </smtp>
</mailSettings>

UPDATE: I added a function to handle the "SendingMail" event:

Protected Sub PasswordRecovery_submit(ByVal sender As Object, ByVal e As WebControls.MailMessageEventArgs) Handles PasswordRecovery.SendingMail

I added a break point in this function but it is never reached, the above error message just comes up in the app. Any other ways to debug what's going wrong?

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

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

发布评论

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

评论(3

晚雾 2024-09-13 16:41:15

您是否记得在 web.config 中声明您的 smtp 部分?默认情况下,密码恢复控件在执行期间使用它。

<system.net>
<mailSettings>
<smtp deliveryMethod="Network">
<network
defaultCredentials="True"
host="localhost"
port="25"
from="[email protected]"/>
</smtp>
</mailSettings>
</system.net>

Have you remembered to declare your smtp section in your web.config? By default the password recovery control uses this during it's execution.

<system.net>
<mailSettings>
<smtp deliveryMethod="Network">
<network
defaultCredentials="True"
host="localhost"
port="25"
from="[email protected]"/>
</smtp>
</mailSettings>
</system.net>
失去的东西太少 2024-09-13 16:41:15

该错误消息是默认的 UserNameFailureText

您确定输入的用户名有效吗?

That error message is the default UserNameFailureText

Are you sure you are entering a valid user name?

旧梦荧光笔 2024-09-13 16:41:15

这是我解决问题的方法。正如 Brian 的答案的评论中提到的,我们的应用程序正在使用自定义电子邮件功能(不能 100% 确定原因,但常规 SMTP 功能不起作用)。无论如何,您可以简单地劫持 PasswordRecovery.SendingMail 事件:

Protected Sub PasswordRecovery_submit(ByVal sender As Object, ByVal e As WebControls.MailMessageEventArgs) Handles PasswordRecovery.SendingMail
    ' do custom email sending here, using the variables in e.Message 

    e.Cancel = False
End Sub

Here is how I solved the problem. As mentioned in the comments on Brian's answer, our app is using a custom email function (not 100% sure why but the regular SMTP stuff just doesn't work). Anyway, you can simply hijack the PasswordRecovery.SendingMail event:

Protected Sub PasswordRecovery_submit(ByVal sender As Object, ByVal e As WebControls.MailMessageEventArgs) Handles PasswordRecovery.SendingMail
    ' do custom email sending here, using the variables in e.Message 

    e.Cancel = False
End Sub
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文