我目前正在使用c#在.net中执行应用程序,我想使用更改密码控件。
问题是......我总是收到“密码不正确或新密码无效。新密码最小长度:1。需要非字母数字字符:0。”
即使我提供了正确的密码参数,并在我的web.config中的Mebership提供程序中设置了(minRequiredPasswordLength =“1”minRequiredNonalphanumericCharacters =“0”)。
<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>
有什么想法吗?感谢。
答案 0 :(得分:0)
我发现了问题,我没有实现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
}
}