如何在asp.net会员中比较密码和用户名?
在创建具有 ASP.NET 成员身份的用户之前,如何确保输入的密码与输入的用户名不匹配?
更新:
我已经尝试设置此设置(在 web.config 文件提供程序部分):
passwordStrengthRegularExpression = "^(?:(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])|(?=.*[a-z])(?=.*[A-Z])(?=.*[!%,.;:])|(?=.*[a-z])(?=.*[0-9])(?=.*[!%,.;:])|(?=.*[A-Z])(?=.*[0-9])(?=.*[!%,.;:]))(?i)(?!.*" + Username + ").+$";
但恐怕将其与这样的用户名进行比较在会员资格中不起作用。
我还认为可以通过一些自定义验证来装饰 AccountModel
中 RegisterModel
类的 Password
属性。
不管怎样,我很困惑,需要建议。
How can you ensure an entered password does not match an entered username before creating a user with ASP.NET Membership?
Update:
I've tried setting this (in the web.config file provider section):
passwordStrengthRegularExpression = "^(?:(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])|(?=.*[a-z])(?=.*[A-Z])(?=.*[!%,.;:])|(?=.*[a-z])(?=.*[0-9])(?=.*[!%,.;:])|(?=.*[A-Z])(?=.*[0-9])(?=.*[!%,.;:]))(?i)(?!.*" + Username + ").+$";
But I'm afraid comparing it to the username like this won't work in Membership.
I also thought I could decorate the Password
property of the RegisterModel
class in AccountModel
with some custom validation.
Either way I am confused and need suggestions.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这不是一个直接的答案,但如果您在
MembershipProvider
配置中设置了最低密码复杂性要求,那么出现这种情况的可能性应该很小。这是在以下 web.config 块中完成的(例如):
It's not a direct answer, but if you set minimum password complexity requirements in the
MembershipProvider
configuration, then there should be little chance of this.This is done in the following web.config block (for example):