更改 PasswordRecovery 控件中锁定用户的错误消息

发布于 2024-12-11 06:46:32 字数 208 浏览 0 评论 0原文

我将 ASP.NET PasswordRecovery 控件与标准成员资格提供程序结合使用。被锁定的用户收到令人困惑的错误消息

我们无法访问您的信息。请重试。

我想更改此消息,但没有办法。属性 XXXFailureText 特别是 GeneralFailureText 包含多个字符串。似乎有一个隐藏文本用于这种特殊类型的错误,我无法使用属性进行更改。

I use the ASP.NET PasswordRecovery control in combination with the standard membership provider. A locked out user gets the confusing error message

We were unable to access your information. Please try again.

I want to change this message, but find no way. The properties XXXFailureText especially GeneralFailureText contain over strings. There seems to be a hidden text used for this special kind of error I can't change using a property.

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

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

发布评论

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

评论(3

救赎№ 2024-12-18 06:46:33

这也让我很头疼,直到我尝试了这个。我向VerifyingUser 事件添加了代码,以在用户被锁定时设置UserNameFaileurText,并且效果很好,即错误消息正是我想要的。

 protected void PasswordRecovery1_VerifyingUser(object sender, LoginCancelEventArgs e)
{
    MembershipUser membershipUser = Membership.GetUser(PasswordRecovery1.UserName);
    if (membershipUser != null && membershipUser.IsLockedOut)
    {
        PasswordRecovery1.UserNameFailureText = string.Format("<span style='font-            size:larger'>Your account has been locked. Please contact<br/>your <a href='mailto:[email protected]?subject=Locked Account - {0}'>system administrator</a>.</span>", PasswordRecovery1.UserName);
    }
}

This was causing me a headache too, until I tried this. I added code to the VerifyingUser event to set the UserNameFaileurText if the user was locked out and it worked great, that is the error message was exactly what I wanted it to be.

 protected void PasswordRecovery1_VerifyingUser(object sender, LoginCancelEventArgs e)
{
    MembershipUser membershipUser = Membership.GetUser(PasswordRecovery1.UserName);
    if (membershipUser != null && membershipUser.IsLockedOut)
    {
        PasswordRecovery1.UserNameFailureText = string.Format("<span style='font-            size:larger'>Your account has been locked. Please contact<br/>your <a href='mailto:[email protected]?subject=Locked Account - {0}'>system administrator</a>.</span>", PasswordRecovery1.UserName);
    }
}
日暮斜阳 2024-12-18 06:46:33

您是否使用自定义会员资格提供商?此错误可能是由部分实现的会员资格提供程序引起的。

您还需要检查 web.config 设置。确保设置了类似的内容:

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

并检查您的邮件设置/smtp 部分是否正确设置了“发件人”电子邮件地址。

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

或者在 PasswordRecovery 中设置“from”

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

顺便说一句,您指定的错误消息是默认的 UserNameFailureTexthttp://msdn.microsoft.com /en-us/library/system.web.ui.webcontrols.passwordrecovery.usernamefailuretext.aspx

如果所有其他方法都失败,您可以劫持事件并取消它们,然后显示你自己的错误消息。特别是 UserLookupError 和其他 *Error 事件。 http://msdn.microsoft.com/en -us/library/system.web.ui.webcontrols.passwordrecovery_events.aspx

Are you using a custom membership provider? This error can be cause by a partially implemented membership provider.

You also need to check you web.config settings. make sure that something like this is set:

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

As well as check they your mailsettings/smtp section is setup properly with a 'from' email address.

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

or set the 'from' in PasswordRecovery

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

btw, your specified error message is the default UserNameFailureText. http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.passwordrecovery.usernamefailuretext.aspx

If all else fails, you could hijack the events and cancel them, then show your own error message. Specially the UserLookupError and the other *Error events. http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.passwordrecovery_events.aspx

叫思念不要吵 2024-12-18 06:46:33

在控件的属性窗口中,有一个用于显示文本的字段,您可以更改该文本

PasswordRecoveryProperties

In the properties window of the control there is a field for the text displayed that you can change

PasswordRecoveryProperties

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