asp.net core mvc password validators(asp.net core mvc 密码验证器)
问题描述
在 asp.net core MVC 中自定义密码验证规则的简单方法是什么?这个问题就像有人在这里遇到的一样 如何在 ASP.Net MVC Identity 2 中更改密码验证? 唯一的区别是我在 Visual Studio 2015 中使用 asp.net CORE MVC(最新版本).我'想删除所有密码验证规则.项目中没有ApplicationUserManager类,也不确定是否可以在Startup.cs文件中自定义UserManager验证规则.
What is the easy way to customize password validation rules in asp.net core MVC? The problem is exactly like someone had here How To Change Password Validation in ASP.Net MVC Identity 2? the only difference is that I'm using asp.net CORE MVC (latest build) with Visual Studio 2015. I'd like to remove all password validation rules. There is no ApplicationUserManager class in the project, also I'm not sure if it's possible to customize UserManager validation rules in the Startup.cs file.
推荐答案
如果你想简单地禁用一些密码限制(RequireLowercase、RequiredLength 等) - 在 Startup 中配置 IdentityOptions.Password,如下所示:
If you want simply disable some password restrictions (RequireLowercase, RequiredLength etc) - configure IdentityOptions.Password in Startup, like this:
services.Configure<IdentityOptions>(o =>
{
o.Password.RequiredLength = 12;
});
如果你想彻底改变密码验证逻辑 - 实现 IPPasswordValidator 并在 Startup 中注册.
If you want completely change password validation logic - implement IPasswordValidator and register it in Startup.
这篇关于asp.net core mvc 密码验证器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:asp.net core mvc 密码验证器
基础教程推荐
- 如果有人提交恶意软件Nuget包怎么办? 2022-01-01
- 禁止输入少量字符,例如'<'、'&a 2022-01-01
- .NET SerialPort DataReceived 事件未触发 2022-01-01
- 当值可以是对象或空数组时反序列化 JSON 2022-01-01
- Azure Functions:CosmosDBTrigger 未在 Visual Studio 中触发 2022-01-01
- Moq It.Is<>不匹配 2022-01-01
- 如何使用 .Net 检查 Active Directory 服务器是否已启动并正在运行? 2022-01-01
- 我应该在后面的代码中直接使用 Linq To SQL 还是使 2022-01-01
- C# 从 List<List<int>> 中删除重 2022-01-01
- WPF 模态进度窗口 2022-01-01
