// 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.UseSwagger(); app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "BookStore v1")); } app.UseHttpsRedirection(); app.UseCors("TCAPolicy"); app.UseRouting(); app.UseAuthentication(); app.UseAuthorization(); app.UseEndpoints(endpoints => { endpoints.MapControllers(); }); app.UseStaticFiles(new StaticFileOptions { FileProvider = new PhysicalFileProvider( Path.Combine(env.WebRootPath, "images")), RequestPath = "/images" }); AppDbInitializer.Seed(app); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, UserManager <AppUser> userManager, RoleManager <IdentityRole> roleManager) { app.UseAuthentication(); //app.UseCors(builder => builder // .AllowAnyOrigin() // .AllowAnyMethod() // .AllowAnyHeader() // .AllowCredentials()); app.UseMvcWithDefaultRoute(); AppDbInitializer.Seed(userManager, roleManager).Wait(); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory, AppDbInitializer dbInitializer, CloudMedicDbContext context) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseCors("AllowAll"); app.UseAuthentication(); app.UseMvc(); IServiceProvider serviceProvider = app.ApplicationServices.CreateScope().ServiceProvider; var dbContext = (CloudMedicDbContext)serviceProvider.GetRequiredService <CloudMedicDbContext>(); context.Database.Migrate(); dbInitializer.Seed().Wait(); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerFactory loggerFactory) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); app.UseSwagger(); app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "book_service v1")); } app.UseHttpsRedirection(); app.UseRouting(); app.UseAuthorization(); app.UseEndpoints(endpoints => { endpoints.MapControllers(); }); // Added : AppDbInitializer.Seed(app); }
public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseExceptionHandler("/Error"); app.UseHsts(); } app.UseHttpsRedirection(); app.UseStaticFiles(); app.UseSpaStaticFiles(); app.UseRouting(); app.Map(new PathString(""), client => { var clientPath = Path.Combine(Directory.GetCurrentDirectory(), "./ClientApp/dist"); StaticFileOptions clientAppDist = new StaticFileOptions() { FileProvider = new PhysicalFileProvider(clientPath) }; client.UseSpaStaticFiles(clientAppDist); client.UseSpa(spa => { spa.Options.DefaultPageStaticFileOptions = clientAppDist; }); app.UseEndpoints(endpoints => { endpoints.MapControllerRoute(name: "default", pattern: "{controller}/{action=Index}/{id?}"); }); }); using (var serviceScope = app.ApplicationServices.GetRequiredService <IServiceScopeFactory>().CreateScope()) { //Seed method AppDbInitializer.Seed(serviceScope); } }