/// <summary> /// This required method gets called by the runtime. Use this method to configure the HTTP request pipeline. /// </summary> /// <param name="app">IApplicationBuilder</param> /// <param name="env">IWebHostEnvironment</param> /// <param name="logger">ILogger<Startup></param> /// <param name="lifetime">IHostApplicationLifetime</param> /// <param name="dbContext">CDCavellDbContext</param> /// <method>Configure(IApplicationBuilder app, IWebHostEnvironment env, ILogger<Startup> logger, IHostApplicationLifetime lifetime, CDCavellDbContext dbContext)</method> public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILogger <Startup> logger, IHostApplicationLifetime lifetime, CDCavellDbContext dbContext) { _logger = new Logger(logger); _logger.Trace($"Configure(IApplicationBuilder: {app}, IWebHostEnvironment: {env}, ILogger<Startup> {logger}, IHostApplicationLifetime: {lifetime})"); AESGCM.Seed(_appSettings.SecretKey); DbInitializer.Initialize(dbContext); new Sitemap(_logger, _webHostEnvironment, _appSettings).Create(dbContext); lifetime.ApplicationStarted.Register(OnAppStarted); lifetime.ApplicationStopping.Register(OnAppStopping); lifetime.ApplicationStopped.Register(OnAppStopped); app.UseForwardedHeaders(new ForwardedHeadersOptions { ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto }); app.UseExceptionHandler("/Home/Error/500"); app.UseStatusCodePagesWithRedirects("~/Home/Error/{0}"); app.UseXMLSitemap(env.ContentRootPath); if (env.EnvironmentName.Equals("Production")) { app.UseHsts(); app.UseHttpsRedirection(); } app.UseRouting(); app.UseAuthentication(); app.UseAuthorization(); app.UseStaticFiles(new StaticFileOptions { OnPrepareResponse = ctx => { const int durationInSeconds = 60 * 60 * 24 * 365; ctx.Context.Response.Headers[HeaderNames.CacheControl] = "public,max-age=" + durationInSeconds; } }); app.UseCookiePolicy(); app.UseEndpoints(endpoints => { endpoints.MapDefaultControllerRoute(); }); }
/// <summary> /// This required method gets called by the runtime. Use this method to configure the HTTP request pipeline. /// </summary> /// <param name="app">IApplicationBuilder</param> /// <param name="env">IWebHostEnvironment</param> /// <param name="logger">ILogger<Startup></param> /// <param name="lifetime">IHostApplicationLifetime</param> /// <param name="dbContext">AuthorizationServiceDbContext</param> /// <method>Configure(IApplicationBuilder app, IWebHostEnvironment env, ILogger<Startup> logger, IHostApplicationLifetime lifetime, AuthorizationServiceDbContext dbContext)</method> public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILogger <Startup> logger, IHostApplicationLifetime lifetime, AuthorizationServiceDbContext dbContext) { _logger = new Logger(logger); _logger.Trace($"Configure(IApplicationBuilder: {app}, IWebHostEnvironment: {env}, ILogger<Startup> {logger}, IHostApplicationLifetime: {lifetime})"); AESGCM.Seed(_appSettings.SecretKey); DbInitializer.Initialize(dbContext, _appSettings.SiteAdministrator); lifetime.ApplicationStarted.Register(OnAppStarted); lifetime.ApplicationStopping.Register(OnAppStopping); lifetime.ApplicationStopped.Register(OnAppStopped); app.UseForwardedHeaders(new ForwardedHeadersOptions { ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto }); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } if (env.EnvironmentName.Equals("Production")) { app.UseHsts(); app.UseHttpsRedirection(); } app.UseRouting(); app.UseAuthentication(); app.UseAuthorization(); app.UseEndpoints(endpoints => { endpoints.MapControllers(); }); }
/// <summary> /// This required method gets called by the runtime. Use this method to configure the HTTP request pipeline. /// </summary> /// <param name="app">IApplicationBuilder</param> /// <param name="env">IWebHostEnvironment</param> /// <param name="logger">ILogger<Startup></param> /// <param name="lifetime">IHostApplicationLifetime</param> /// <method>Configure(IApplicationBuilder app, IWebHostEnvironment env, ILogger<Startup> logger, IHostApplicationLifetime lifetime)</method> public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILogger <Startup> logger, IHostApplicationLifetime lifetime) { _logger = new Logger(logger); _logger.Trace($"Configure(IApplicationBuilder: {app}, IWebHostEnvironment: {env}, ILogger<Startup> {logger}, IHostApplicationLifetime: {lifetime})"); AESGCM.Seed(_appSettings.SecretKey); lifetime.ApplicationStarted.Register(OnAppStarted); lifetime.ApplicationStopping.Register(OnAppStopping); lifetime.ApplicationStopped.Register(OnAppStopped); app.UseForwardedHeaders(new ForwardedHeadersOptions { ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto }); app.UseExceptionHandler("/Home/Error/500"); app.UseStatusCodePagesWithRedirects("~/Home/Error/{0}"); if (env.EnvironmentName.Equals("Production")) { app.UseHsts(); app.UseHttpsRedirection(); } app.UseRouting(); app.UseIdentityServer(); app.UseAuthorization(); app.UseStaticFiles(); app.UseEndpoints(endpoints => { endpoints.MapDefaultControllerRoute(); }); }