// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, UserManager <ApplicationUser> userManager, RoleManager <IdentityRole> roleManager) { if (env.IsDevelopment()) { app.UseBrowserLink(); app.UseDeveloperExceptionPage(); app.UseDatabaseErrorPage(); } else { app.UseExceptionHandler("/Home/Error"); } app.UseStaticFiles(); app.UseAuthentication(); Console.WriteLine("seeding"); IdentityDataInitializer.SeedData(userManager, roleManager); IdentityDataInitializer.SeedRoles(roleManager); IdentityDataInitializer.SeedUsers(userManager); app.UseMvc(routes => { routes.MapRoute( name: "default", template: "{controller=Home}/{action=Index}/{id?}"); }); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); //app.UseMigrationsEndPoint(); } else { app.UseExceptionHandler("/Home/Error"); // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. app.UseHsts(); } using (var serviceScope = app.ApplicationServices.GetService <IServiceScopeFactory>().CreateScope()) { serviceScope.ServiceProvider.GetRequiredService <AppIdentityDbContext>().Database.EnsureCreated(); var userManager = serviceScope.ServiceProvider. GetRequiredService <UserManager <ApplicationUser> >(); IdentityDataInitializer.SeedUsers(userManager); } app.UseHttpsRedirection(); app.UseStaticFiles(); app.UseRouting(); app.UseAuthentication(); app.UseAuthorization(); app.UseEndpoints(endpoints => { endpoints.MapControllerRoute( name: "default", pattern: "{controller=Home}/{action=Index}/{id?}"); endpoints.MapRazorPages(); }); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, UserManager <User> userManager) { app.UseCors("AllowAll"); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); app.UseBrowserLink(); app.UseDatabaseErrorPage(); } else { app.UseExceptionHandler("/Error"); } app.UseStaticFiles(); app.UseIdentityServer(); IdentityDataInitializer.SeedUsers(userManager); app.UseMvc(routes => { routes.MapRoute( name: "default", template: "{controller}/{action=Index}/{id?}"); }); // storage manipulations should be scoped using (var serviceScope = app.ApplicationServices .GetRequiredService <IServiceScopeFactory>().CreateScope()) { serviceScope.ServiceProvider.GetService <IDataStorageControl>().Init(); } }