Reputation: 5062
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.
Upvotes: 2
Views: 3147
Reputation: 106
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);
}
}
Upvotes: 8
Reputation: 3716
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
Upvotes: 2
Reputation: 2358
In the properties window of the control there is a field for the text displayed that you can change
Upvotes: 0