如何在 Razor 页面获取 RequireConfirmedAccount?

How to get RequireConfirmedAccount in Razor page?

如何检索我在身份服务注入中设置的 SignInOptions.RequireConfirmedAccount 值(在我的例子中为 false)?

builder.Services.AddDefaultIdentity<IdentityUser>(options => options.SignIn.RequireConfirmedAccount = false).AddEntityFrameworkStores<ApplicationDbContext>();

终于找到答案了

    private readonly UserManager<IdentityUser> _userManager;

    public MyModel(UserManager<IdentityUser> userManager)
    {
        _userManager = userManager;
    }

然后在页面的任意位置,使用

_userManager.Options.SignIn.RequireConfirmedAccount