问题描述
如果我叫user.ChangePassword(oldpass,newpass),和旧的密码是错误的,或者新的密码不符合供应商的复杂性要求,该方法失败没有警告。有没有什么办法,我可以找出是否存在错误,并指明是什么错误。
If I call user.ChangePassword(oldpass,newpass), and the old password is wrong, or the new password does not meet the provider's complexity requirement , the method fails without warning. is there any way i can find out if there is an error and what the error was.
我可以随时把这些检查在我的code,但应该有办法使用API的成员做
I can always put these checks in my code, but there should be a way to do it using the Membership APIs
推荐答案
可惜不是。在<$c$c>ChangePassword$c$c>方法只返回一个成功的简单的布尔/失败。
Unfortunately not. The ChangePassword
method only returns a simple bool for success/fail.
这是失败最好的选择将显示一个普通的信息给用户,指出所有可能失败的原因...例如。
Your best option on fail would be to display a generic message to the user stating all possible failure reasons... e.g.
无法更改密码。结果
这可能是因为发生:结果
Failed to Change Password.
This may have occured because:
- 旧的密码是不正确
- 新密码不符合要求的complexibility
- 新密码必须是8个字符长,至少包含2个数字字符。 (或其他)
如果你想给更多具体信息,然后如你所说,你需要实现一个规则检查在自己的code和传递信息的基础上,办理入住手续的用户。
If you want to give more specific information, then as you said, you would need to implement a rules checker in your own code and relay information to the user based on that check.
这篇关于MembershipUser.ChangePassword失败没有警告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!