将 ASP.NET 样板模块零与 IdentityServer4 集成
Integrating ASP.NET Boilerplate Module zero with IdentityServer4
我正在尝试将 IdentityServer4 与 ASP.NET 样板模块零一起使用,但出现一些错误
我正在尝试关注这个 link
http://docs.identityserver.io/en/release/quickstarts/6_aspnet_identity.html
我的 ConfigureServices 函数
public IServiceProvider ConfigureServices(IServiceCollection services)
{
var connectionString = @"Server=localhost\SQLEXPRESS; Database=MyDb;User Id=sa; password=sa;";
// configure identity server with in-memory users, but EF stores for clients and resources
var migrationsAssembly = typeof(Startup).GetTypeInfo().Assembly.GetName().Name;
services.AddIdentityServer()
.AddTemporarySigningCredential()
.AddConfigurationStore(builder =>
builder.UseSqlServer(connectionString, options =>
options.MigrationsAssembly(migrationsAssembly)))
.AddOperationalStore(builder =>
builder.UseSqlServer(connectionString, options =>
options.MigrationsAssembly(migrationsAssembly)))
.AddAspNetIdentity<User>();
//MVC
services.AddMvc(options =>
{
options.Filters.Add(new AutoValidateAntiforgeryTokenAttribute());
});
services.AddIdentity<User, Role>();
//Configure Abp and Dependency Injection
return services.AddAbp<EventoTixWebModule>(options =>
{
//Configure Log4Net logging
options.IocManager.IocContainer.AddFacility<LoggingFacility>(
f => f.UseAbpLog4Net().WithConfig("log4net.config")
);
});
}
我的配置函数
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
// this will do the initial DB population
InitializeDatabase(app);
//loggerFactory.AddConsole(Configuration.GetSection("Logging"));
//loggerFactory.AddDebug();
app.UseAbp(); //Initializes ABP framework.
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
//app.UseDatabaseErrorPage();
app.UseBrowserLink();
}
else
{
app.UseExceptionHandler("/Home/Error");
}
app.UseStaticFiles();
//Integrate to OWIN
app.UseAppBuilder(ConfigureOwinServices);
//app.UseIdentity();
app.UseIdentityServer();
app.UseMvc(routes =>
{
routes.MapRoute(
name: "default",
template: "{controller=Home}/{action=Index}/{id?}");
});
}
在 运行 应用程序之后我收到此错误
'Microsoft.AspNetCore.Identity.UserManager1[[EventoTix.Users.User,
EventoTix.Core, Version=1.0.0.0, Culture=neutral,
PublicKeyToken=null]]_b66a8aa6-a49b-47c6-a3b3-d6e943ee4c47' is waiting
for the following dependencies:
- Service 'Microsoft.AspNetCore.Identity.IUserStore1[[EventoTix.Users.User,
EventoTix.Core, Version=1.0.0.0, Culture=neutral,
PublicKeyToken=null]]' which was not registered.
尝试安装
https://www.nuget.org/packages/Microsoft.AspNetCore.Identity/
在 nuget 管理器中。
如果没有帮助,关闭解决方案,找到解决方案文件夹,包文件夹,删除所有那里,再次打开你的解决方案,转到 nuget 包管理器并单击 "restore"
我从 Halil İbrahim Kalkan 那里得到了答案
他说模块零模板使用 EF 6.x,而不是 EF Core。此外,Abp.Zero 包基于 Identity 2.x,而不是 Identity Core。所以,他们不兼容。
参考:
https://github.com/aspnetboilerplate/aspnetboilerplate/issues/961
我正在尝试将 IdentityServer4 与 ASP.NET 样板模块零一起使用,但出现一些错误
我正在尝试关注这个 link http://docs.identityserver.io/en/release/quickstarts/6_aspnet_identity.html
我的 ConfigureServices 函数
public IServiceProvider ConfigureServices(IServiceCollection services)
{
var connectionString = @"Server=localhost\SQLEXPRESS; Database=MyDb;User Id=sa; password=sa;";
// configure identity server with in-memory users, but EF stores for clients and resources
var migrationsAssembly = typeof(Startup).GetTypeInfo().Assembly.GetName().Name;
services.AddIdentityServer()
.AddTemporarySigningCredential()
.AddConfigurationStore(builder =>
builder.UseSqlServer(connectionString, options =>
options.MigrationsAssembly(migrationsAssembly)))
.AddOperationalStore(builder =>
builder.UseSqlServer(connectionString, options =>
options.MigrationsAssembly(migrationsAssembly)))
.AddAspNetIdentity<User>();
//MVC
services.AddMvc(options =>
{
options.Filters.Add(new AutoValidateAntiforgeryTokenAttribute());
});
services.AddIdentity<User, Role>();
//Configure Abp and Dependency Injection
return services.AddAbp<EventoTixWebModule>(options =>
{
//Configure Log4Net logging
options.IocManager.IocContainer.AddFacility<LoggingFacility>(
f => f.UseAbpLog4Net().WithConfig("log4net.config")
);
});
}
我的配置函数
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
// this will do the initial DB population
InitializeDatabase(app);
//loggerFactory.AddConsole(Configuration.GetSection("Logging"));
//loggerFactory.AddDebug();
app.UseAbp(); //Initializes ABP framework.
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
//app.UseDatabaseErrorPage();
app.UseBrowserLink();
}
else
{
app.UseExceptionHandler("/Home/Error");
}
app.UseStaticFiles();
//Integrate to OWIN
app.UseAppBuilder(ConfigureOwinServices);
//app.UseIdentity();
app.UseIdentityServer();
app.UseMvc(routes =>
{
routes.MapRoute(
name: "default",
template: "{controller=Home}/{action=Index}/{id?}");
});
}
在 运行 应用程序之后我收到此错误
'Microsoft.AspNetCore.Identity.UserManager1[[EventoTix.Users.User, EventoTix.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]_b66a8aa6-a49b-47c6-a3b3-d6e943ee4c47' is waiting for the following dependencies: - Service 'Microsoft.AspNetCore.Identity.IUserStore1[[EventoTix.Users.User, EventoTix.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]' which was not registered.
尝试安装 https://www.nuget.org/packages/Microsoft.AspNetCore.Identity/ 在 nuget 管理器中。
如果没有帮助,关闭解决方案,找到解决方案文件夹,包文件夹,删除所有那里,再次打开你的解决方案,转到 nuget 包管理器并单击 "restore"
我从 Halil İbrahim Kalkan 那里得到了答案
他说模块零模板使用 EF 6.x,而不是 EF Core。此外,Abp.Zero 包基于 Identity 2.x,而不是 Identity Core。所以,他们不兼容。
参考: https://github.com/aspnetboilerplate/aspnetboilerplate/issues/961