更改密码控制不起作用
本文关键字:不起作用 控制 密码 | 更新日期: 2023-09-27 18:07:19
我目前正在使用c#在。net中做一个应用程序,我想使用更改密码控件。
问题是……我总是收到"密码不正确或新密码无效"的错误提示。新密码长度最小:1。所需的非字母数字字符:0。"
即使我在我的web.config中提供了正确的密码参数并设置了(minRequiredPasswordLength="1" minRequiredNonalphanumericCharacters="0")在membership provider .
<asp:ChangePassword ID="ChangePassword1" runat="server" BackColor="#EFF3FB" BorderColor="#B5C7DE"
BorderPadding="4" BorderStyle="Solid" BorderWidth="1px" Font-Names="Verdana"
Font-Size="0.8em" ForeColor="#333333"
ChangePasswordButtonText="Change"
ChangePasswordTitleText="Password change"
ConfirmNewPasswordLabelText="Retype new password:"
NewPasswordLabelText="New Password:">
</asp:ChangePassword>
我正在实现我自己的MembershipProvider:
public class MyMembershipProvider : MembershipProvider
{
...
public override int MinRequiredNonAlphanumericCharacters
{
get
{
return 0;
}
}
...
}
web . config:
<membership defaultProvider="MyMembershipProvider" userIsOnlineTimeWindow="15">
<providers>
<add name="MyMembershipProvider"
type="My.Security.BsAsMembershipProvider"
enablePasswordRetrieval="true"
enablePasswordReset="true"
requiresQuestionAndAnswer="false"
applicationName="MyApp"
requiresUniqueEmail="true"
passwordFormat="Clear"
passwordStrengthRegularExpression=""
minRequiredNonalphanumericCharacters="0"
description="My custom membership provider"
/>
</providers>
</membership>
任何想法?谢谢。
我发现了问题,我没有实现MyMemberShipUser ChangePassword方法。
public class MyMembershipUser : MembershipUser
{
public MyMembershipUser()
{
}
public MyMembershipUser(string username)
: base("MyMembershipProvider", username, null, "", "", "", true, true, DateTime.Today, DateTime.Today, DateTime.Today, DateTime.Today, DateTime.Today)
{
}
public override bool ChangePassword(string oldPassword, string newPassword)
{
//Do something
}
}