using Microsoft.AspNetCore.Builder; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Volo.Abp; using Volo.Abp.AspNetCore.Mvc; using Volo.Abp.Autofac; using Volo.Abp.Data; using Volo.Abp.EntityFrameworkCore; using Volo.Abp.EntityFrameworkCore.SqlServer; using Volo.Abp.Identity.AspNetCore; using Volo.Abp.Identity.EntityFrameworkCore; using Volo.Abp.IdentityServer.EntityFrameworkCore; using Volo.Abp.Modularity; namespace IdentityServerHost { [DependsOn( typeof(AbpAutofacModule), typeof(AbpAspNetCoreMvcModule), typeof(AbpIdentityAspNetCoreModule), typeof(AbpIdentityServerEntityFrameworkCoreModule), typeof(AbpIdentityEntityFrameworkCoreModule), typeof(AbpEntityFrameworkCoreSqlServerModule) )] public class IdentityServerHostModule : AbpModule { public override void ConfigureServices(ServiceConfigurationContext context) { var hostingEnvironment = context.Services.GetHostingEnvironment(); var configuration = context.Services.BuildConfiguration(); Configure(options => { options.ConnectionStrings.Default = configuration.GetConnectionString("Default"); }); Configure(options => { options.UseSqlServer(); }); Configure(iis => { iis.AuthenticationDisplayName = "Windows"; iis.AutomaticAuthentication = false; }); context.Services.AddDistributedSqlServerCache(options => { options.ConnectionString = configuration.GetConnectionString("SqlServerCache"); options.SchemaName = "dbo"; options.TableName = "TestCache"; }); } public override void OnApplicationInitialization(ApplicationInitializationContext context) { var app = context.GetApplicationBuilder(); app.UseVirtualFiles(); app.UseAuthentication(); app.UseIdentityServer(); app.UseMvcWithDefaultRoute(); SeedData(context); } private void SeedData(ApplicationInitializationContext context) { using (var scope = context.ServiceProvider.CreateScope()) { scope.ServiceProvider .GetRequiredService() .Seed(); } } } }