如何在ASP.Net Core 2.0中注入RoleManager?
我收到以下错误:
无法解析类型的服务 用于ASP.Net Core 2.0的Microsoft.AspNetCore.Identity.RoleManager
我有以下代码:
// add identity
var builder = services.AddIdentityCore<AppUser>(o =>
{
// configure identity options
o.Password.RequireDigit = false;
o.Password.RequireLowercase = false;
o.Password.RequireUppercase = false;
o.Password.RequireNonAlphanumeric = false;
o.Password.RequiredLength = 6;
});
builder = new IdentityBuilder(builder.UserType, typeof(AppRole), builder.Services);
builder.AddSignInManager<SignInManager<AppUser>>();
AppUser和AppRole分别来自IdentityUser和IdentityRole。
答案 0 :(得分:2)
我不确定您使用AddIdentity()
的原因。您是否尝试过传统的services.AddIdentity<AppUser, AppRole>(options =>
{
...
});
:
bootstrap.scss