PasswordHaserOptions的AspNetCore AspIdentity依赖注入

时间:2019-06-12 02:33:52

标签: c# asp.net-core dependency-injection .net-core

如何提供默认PasswordHasherOptions的替代,以便AspNetCore V3 PasswordHasher使用PasswordHasherOptions V2

V3 PasswordHasher extension default constructor 需要IOptions<PasswordHasherOptions>,什么是AddSingleton ???提供自定义PasswordHasherOptions的语法?将PasswordHasherCompatibilityMode设置为'IdentityV2'

Aspidentity 2.2 (framework 4.x) reused on AspnetCore AspIdentity

有关

1 个答案:

答案 0 :(得分:1)

使用services.Configure(在Startup.ConfigureServices中)注册IOptions配置对象。在这种情况下,最简单的方法是使用overload that takes a delegate

services.Configure<PasswordHasherOptions>(o => o.CompatibilityMode = PasswordHasherCompatibilityMode.IdentityV2);