ASP.NET 用户名与密码约束规则
"Microsoft.AspNet.Identity.EntityFramework" version="2.2.3" targetFramework="net48"
修改IdentityModels.cs文件
public class UserManager : UserManager<ApplicationUser> { public UserManager() : base(new UserStore<ApplicationUser>(new ApplicationDbContext())) { //PasswordValidator = new MinimumLengthValidator(8); PasswordValidator = new PasswordValidator { RequiredLength = 8, RequireNonLetterOrDigit = true, RequireDigit = true, RequireLowercase = true, RequireUppercase = true, }; UserValidator = new UserValidator<ApplicationUser>(this) { AllowOnlyAlphanumericUserNames = false }; } }
高亮部分为密码和用户名约束条件设置
参考:
密码约束规则:https://docs.microsoft.com/en-us/previous-versions/aspnet/dn613295(v=vs.108)?redirectedfrom=MSDN
用户名约束规则:https://docs.microsoft.com/zh-cn/previous-versions/visualstudio/dn468202(v=vs.111)
转载请注明出处:https://www.cnblogs.com/lei-zi/