How To Change Password Validation in ASP.Net MVC Identity 2?

asp.net Mvcasp.net Identityasp.net Identity-2

asp.net Mvc Problem Overview


How To Change Password Validation in ASP.Net MVC5 Identity 2 ?

Thanks

asp.net Mvc Solutions


Solution 1 - asp.net Mvc

In the MVC project template in VS2013 Update 2, there should be a file called App_Start/IdentityConfig.cs. In it you should find the class ApplicationUserManager and a static factory method called Create(). That's where the user manager class is configured, including the server-side validation rules for passwords are defined. For example:

manager.PasswordValidator = new PasswordValidator
{
    RequiredLength = 6,
    RequireNonLetterOrDigit = true,
    RequireDigit = true,
    RequireLowercase = true,
    RequireUppercase = true,
};

Solution 2 - asp.net Mvc

In addition to Anthony Chu's answer,

You may also need to change it in Models folder > AccountViewModel.cs > class RegisterViewModel (as well as class ResetPasswordViewModel)

Change "MinimumLength = 6" (need to scroll right)

 [Required]
 [StringLength(100, ErrorMessage = "The {0} must be at least {2} characters long.", MinimumLength = 6)]
 [DataType(DataType.Password)]
 [Display(Name = "Password")]
 public string Password { get; set; }

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionNazmul HossainView Question on Stackoverflow
Solution 1 - asp.net MvcAnthony ChuView Answer on Stackoverflow
Solution 2 - asp.net MvcnanonerdView Answer on Stackoverflow