// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, IDbInitializer dbInitializer) { app.UseCors(CORS_POLICY_ALLOW_ALL); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); app.UseBrowserLink(); app.UseDatabaseErrorPage(); // Disable telemetry. Based on https://github.com/aspnet/Home/issues/2051 var configuration = app.ApplicationServices.GetService <TelemetryConfiguration>(); if (configuration != null) { configuration.DisableTelemetry = true; } } else { app.UseExceptionHandler("/Home/Error"); } app.UseStaticFiles(); app.UseIdentityServer(); app.UseAuthentication(); dbInitializer?.Initialize(); app.UseMvcWithDefaultRoute(); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env, IDbInitializer dbInitializer) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); app.UseDatabaseErrorPage(); } 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(); } app.UseHttpsRedirection(); app.UseStaticFiles(); app.UseRouting(); StripeConfiguration.ApiKey = Configuration.GetSection("Stripe")["SecretKey"]; app.UseSession(); app.UseAuthentication(); app.UseAuthorization(); dbInitializer.Initialize(); app.UseEndpoints(endpoints => { endpoints.MapControllerRoute( name: "default", pattern: "{area=Customer}/{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, IDbInitializer dbInitializer) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); app.UseBrowserLink(); app.UseDatabaseErrorPage(); } else { app.UseExceptionHandler("/Home/Error"); } app.UseStaticFiles(); app.UseAuthentication(); app.UseMvc(routes => { routes.MapRoute( name: "default", template: "{controller=Home}/{action=Index}/{id?}"); }); //DataSeeder.SeedData(app); dbInitializer.Initalize(); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env, IDbInitializer dbInitializer) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); app.UseDatabaseErrorPage(); } else { app.UseExceptionHandler("/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(); } dbInitializer.Initialize(); app.UseHttpsRedirection(); app.UseStaticFiles(); app.UseRouting(); app.UseAuthentication(); app.UseAuthorization(); app.UseEndpoints(endpoints => { endpoints.MapControllers(); endpoints.MapRazorPages(); }); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env, IDbInitializer dbInitializer) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseHsts(); } app.UseOpenApi(); app.UseSwaggerUi3(x => { x.DocExpansion = "list"; }); app.UseHttpsRedirection(); app.UseRouting(); app.UseEndpoints(endpoints => { endpoints.MapControllers(); }); dbInitializer.InitializeDb(); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, IDbInitializer dbInitializer) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); app.UseBrowserLink(); app.UseDatabaseErrorPage(); } else { app.UseExceptionHandler("/Home/Error"); } app.UseDefaultFiles(); app.UseStaticFiles(); app.UseAuthentication(); dbInitializer.Initialize().Wait(); app.UseMvc(routes => { routes.MapRoute(name: "default", template: "{controller=Home}/{action=Index}"); routes.MapSpaFallbackRoute(name: "spa_fallback", defaults: new { controller = "Home", action = "Index" }); }); //app.UseMvcWithDefaultRoute(); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, IDbInitializer dbInitializer) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); app.UseDatabaseErrorPage(); } 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(); } StripeConfiguration.ApiKey = Configuration.GetSection("Stripe")["SecretKey"]; dbInitializer.Initialize(); app.UseHttpsRedirection(); app.UseStaticFiles(); app.UseCookiePolicy(); app.UseSession(); app.UseAuthentication(); app.UseMvc(routes => { routes.MapRoute( name: "areas", template: "{area=Customer}/{controller=Home}/{action=Index}/{id?}"); }); }
public Worker(ILogger <Worker> logger, MqttConsumer mqttService, IHostApplicationLifetime hostApplicationLifetime, IDbInitializer dbInitializer) { _logger = logger; _mqttService = mqttService; _hostApplicationLifetime = hostApplicationLifetime; _dbInitializer = dbInitializer; }
public void ConfigureTesting(IApplicationBuilder app, IDbInitializer dbInitializer) { dbInitializer.Initialize(); app.UseAuthentication() // .UseRewriter(new RewriteOptions().AddRedirectToHttps()) .UseMvcWithDefaultRoute(); }
public void Configure() { IServiceCollection services = new ServiceCollection(); services.AddOptions(); services.AddMemoryCache(); List <ExchangeRateProviderOption> exchangeRateProviders = new List <ExchangeRateProviderOption> { new ExchangeRateProviderOption { Name = "Default" } }; services.Configure <ExchangeRateSettings>(o => { o.Providers = exchangeRateProviders; }); services.Configure <DbSettings>(o => { o.SystemDefaultCurrency = "USD"; }); ConfigureTestInMemoryDb(services); services.AddApplicationServices(); ConfigureExchangeRates(services); ConfigureBankIntegration(services); Services = services.BuildServiceProvider(); IDbInitializer dbInitializer = Services.GetRequiredService <IDbInitializer>(); dbInitializer.EnsureCreated(); }
public void Configure(IApplicationBuilder app, IWebHostEnvironment env, IDbInitializer dbInitializer) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); app.UseDatabaseErrorPage(); } else { app.UseExceptionHandler("/Home/Error"); app.UseHsts(); } app.UseHttpsRedirection(); app.UseStaticFiles(); app.UseRouting(); app.UseAuthentication(); app.UseAuthorization(); dbInitializer.Initialize(); app.UseEndpoints(endpoints => { endpoints.MapControllerRoute( "default", "{area=User}/{controller=Home}/{action=Index}/{id?}"); endpoints.MapRazorPages(); }); }
public void Configure(IApplicationBuilder app, IWebHostEnvironment env, IDbInitializer dbInitializer) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseExceptionHandler("/Error"); app.UseHsts(); } app.UseHttpsRedirection(); app.UseStaticFiles(); app.UseRouting(); app.UseAuthentication(); app.UseAuthorization(); dbInitializer.Initialize(); // Seed admin user and another roles to database. app.UseEndpoints(endpoints => { endpoints.MapBlazorHub(); endpoints.MapFallbackToPage("/_Host"); }); }
public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory, IDbInitializer dbInitializer) { if (Environment.IsDevelopment()) { app.UseBrowserLink(); app.UseDeveloperExceptionPage(); app.UseDatabaseErrorPage(); } else { app.UseExceptionHandler("/Home/Error"); } app.UseDefaultFiles(); app.UseStaticFiles(); app.UseHttpsRedirection(); app.UseCors("default"); app.UseAuthentication(); loggerFactory.AddConsole(Configuration.GetSection("Logging")); loggerFactory.AddDebug(); dbInitializer.Initialize(); app.UseMvc(routes => { routes.MapRoute( name: "default", template: "{controller=Home}/{action=Index}/{id?}"); }); }
public void Configure(IApplicationBuilder app, IWebHostEnvironment env, IDbInitializer dbInitializer) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); app.UseWebAssemblyDebugging(); } else { app.UseExceptionHandler("/Error"); app.UseHsts(); } app.UseHttpsRedirection(); app.UseBlazorFrameworkFiles(); app.UseStaticFiles(); app.UseRouting(); app.UseAuthentication(); app.UseAuthorization(); dbInitializer.Initialize(); // Seed users and roles to database. app.UseEndpoints(endpoints => { endpoints.MapRazorPages(); endpoints.MapControllers(); endpoints.MapFallbackToFile("index.html"); }); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, IDbInitializer dbInitializer) { if (env.IsDevelopment()) { app.UseBrowserLink(); app.UseDeveloperExceptionPage(); app.UseDatabaseErrorPage(); } else { app.UseExceptionHandler("/Home/Error"); } app.UseStaticFiles(); app.UseAuthentication(); // Black magic warning, this makes sure the db context remains intact during initialize. Otherwise the dbcontext will be disposed during init ((DbInitializer)dbInitializer).Initialize().Wait(); 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, IDbInitializer dbInitializer, ILoggerFactory loggerFactory) { var path = Directory.GetCurrentDirectory(); loggerFactory.AddFile($"{path}\\Logs\\Log.txt"); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); app.UseDatabaseErrorPage(); } 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(); } app.UseHttpsRedirection(); app.UseStaticFiles(); app.UseRouting(); app.UseSession(); app.UseAuthentication(); app.UseAuthorization(); dbInitializer.Initialize(); app.UseEndpoints(endpoints => { endpoints.MapControllerRoute( name: "default", pattern: "{area=Customer}/{controller=Home}/{action=Index}/{id?}"); endpoints.MapRazorPages(); }); }
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory, IDbInitializer dbSeeder) { app.UseCors(env.IsDevelopment() ? "AllowAnyOrigin" : "AllowSpecificOrigin"); app.AddLogging(loggerFactory, env.IsDevelopment()); app.AddNLogWeb(); app.UseJwtBearerAuthentication(new JwtBearerOptions { AutomaticAuthenticate = true, AutomaticChallenge = true, TokenValidationParameters = new TokenValidationParameters { ValidIssuer = MongoAppConfig.TokenConfigs.Issuer, ValidAudience = MongoAppConfig.TokenConfigs.Audience, ValidateIssuerSigningKey = true, IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(MongoAppConfig.TokenConfigs.Key)), ValidateLifetime = true } }); app.UseMvc(); AutoMapper.Mapper.Initialize(cfg => { cfg.CreateMap <UserDocument, AppUserDto>() .ForMember(dest => dest.TaskCount, opt => opt.MapFrom(src => src.Tasks.Count)); cfg.CreateMap <TaskDocument, AppUserTaskDto>(); cfg.CreateMap <AddTaskDto, TaskDocument>(); cfg.CreateMap <TaskUpdateDto, TaskDocument>(); }); dbSeeder.EnsureSeedData(); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env, IDbInitializer dbInitializer) { app.UseMiddleware <ErrorHandlingMiddleware>(); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseHttpsRedirection(); app.UseDefaultFiles(); app.UseStaticFiles(); app.UseRouting(); app.UseCors("CORS Policy"); app.UseAuthentication(); app.UseAuthorization(); dbInitializer.Initialize(); app.UseEndpoints(endpoints => { endpoints.MapControllers(); endpoints.MapControllerRoute( name: "default", pattern: "{controller=ProductManagement}/{action=GetProducts}/{id?}" ); }); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env, IDbInitializer init) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } 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(); } app.UseHttpsRedirection(); app.UseStaticFiles(); app.UseRouting(); app.UseAuthorization(); app.UseAuthentication(); init.Initalize(); app.UseEndpoints(endpoints => { endpoints.MapControllerRoute( name: "default", pattern: "{controller=Account}/{action=Login}/{id?}"); }); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env, IDbInitializer dbInitializer) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseHttpsRedirection(); app.UseStaticFiles(); app.UseRouting(); app.UseAuthentication(); app.UseAuthorization(); dbInitializer.Initialize(); app.UseSwagger(); app.UseSwaggerUI(ui => { ui.SwaggerEndpoint("/swagger/v1.0/swagger.json", "Tuteexy Endpoint"); }); app.UseEndpoints(endpoints => { endpoints.MapControllers(); }); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, IDbInitializer dbInitializer) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); app.UseDatabaseErrorPage(); //app.UseStatusCodePages(); //app.UseStatusCodePagesWithReExecute("/Admin/ErrorCheck/{0}"); } else { //app.UseStatusCodePagesWithRedirects("Admin/Error/{0}"); app.UseExceptionHandler("/Admin/ErrorCheck"); app.UseStatusCodePagesWithReExecute("/Admin/ErrorCheck/{0}"); // The default HSTS value is 30 days. You may want to change this for ú scenarios, see https://aka.ms/aspnetcore-hsts. app.UseHsts(); } dbInitializer.Initialize(); app.UseHttpsRedirection(); app.UseStaticFiles(); app.UseCookiePolicy(); app.UseAuthentication(); app.UseMvc(routes => { routes.MapRoute( name: "areas", template: "{area=User}/{controller=Home}/{action=Index}/{id?}"); }); }
public void Configure(IApplicationBuilder app, IHostingEnvironment env) { app.UseCors("AllowSpecificOrigin"); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); using (var scope = app.ApplicationServices.CreateScope()) { var services = scope.ServiceProvider; var context = scope.ServiceProvider.GetService <UmbrellaShopContext>(); context.Database.EnsureDeleted(); context.Database.EnsureCreated(); var dbInitializer = services.GetService <IDbInitializer>(); dbInitializer.Seed(context); } } else { using (var scope = app.ApplicationServices.CreateScope()) { var context = scope.ServiceProvider.GetRequiredService <UmbrellaShopContext>(); IDbInitializer dbInitializer = scope.ServiceProvider.GetService <IDbInitializer>(); context.Database.EnsureCreated(); dbInitializer.Seed(context); } app.UseHsts(); } app.UseHttpsRedirection(); app.UseAuthentication(); app.UseMvc(); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, IDbInitializer dbInitializer) { var locOptions = app.ApplicationServices.GetService <IOptions <RequestLocalizationOptions> >(); app.UseRequestLocalization(locOptions.Value); app.UseStaticFiles(); if (env.IsDevelopment()) { app.UseBrowserLink(); app.UseDeveloperExceptionPage(); } else { app.UseExceptionHandler("/Home/Error"); } app.UseAuthentication(); dbInitializer.Initialize(); 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, IDbInitializer dbInitializer) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); app.UseDatabaseErrorPage(); } 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(); } app.UseHttpsRedirection(); app.UseStaticFiles(); app.UseRouting(); app.UseForwardedHeaders(new ForwardedHeadersOptions { ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto }); app.UseAuthentication(); app.UseAuthorization(); dbInitializer.Initialize(); app.UseEndpoints(endpoints => { endpoints.MapControllerRoute( name: "default", pattern: "{area=Unauthenticated}/{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, IDbInitializer dbInitializer) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); app.UseDatabaseErrorPage(); } else { app.UseExceptionHandler("/Home/Error"); app.UseHsts(); } app.UseHttpsRedirection(); app.UseStaticFiles(); app.UseCookiePolicy(); dbInitializer.Initialize(); app.UseAuthentication(); app.UseSession(); app.UseMvc(routes => { routes.MapRoute( name: "areas", template: "{area=Admin}/{controller=Statistical}/{action=Index}/{id?}" ); }); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env) { if (env.IsDevelopment()) { using (var scope = app.ApplicationServices.CreateScope()) { RUSTWebApplicationContext context = scope.ServiceProvider.GetService <RUSTWebApplicationContext>(); IDbInitializer dbInitializer = scope.ServiceProvider.GetService <IDbInitializer>(); context.Database.EnsureDeleted(); context.Database.EnsureCreated(); dbInitializer.SeedInMemory(context); } app.UseDeveloperExceptionPage(); } else { using (var scope = app.ApplicationServices.CreateScope()) { RUSTWebApplicationContext context = scope.ServiceProvider.GetService <RUSTWebApplicationContext>(); IDbInitializer dbInitializer = scope.ServiceProvider.GetService <IDbInitializer>(); context.Database.EnsureCreated(); // dbInitializer.SeedAzure(context); } // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. app.UseHsts(); } app.UseCors("AllowSpecificOrigin"); app.UseHttpsRedirection(); app.UseAuthentication(); app.UseMvc(); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. //public void Configure(IApplicationBuilder app, IHostingEnvironment env) //{ // if (env.IsDevelopment()) // { // app.UseDeveloperExceptionPage(); // } // app.UseMvc(); //} public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory, IDbInitializer dbInitializer) { if (CurrentEnvironment.IsDevelopment() || CurrentEnvironment.IsEnvironment("Testing")) { app.UseDeveloperExceptionPage(); dbInitializer.Initialize(); } // Enable middleware to serve generated Swagger as a JSON endpoint. app.UseSwagger() .UseDefaultFiles() .UseStaticFiles() // Enable middleware to serve swagger-ui (HTML, JS, CSS, etc.), specifying the Swagger JSON endpoint. .UseSwaggerUI(c => { c.SwaggerEndpoint("/swagger/v1/swagger.json", "Core2 API Exercise V1"); }); app.UseMvc(); //app.UseRewriter(new RewriteOptions().AddRedirectToHttps()) //app.UseRewriter(new RewriteOptions()) // .UseDefaultFiles() // .UseStaticFiles() // .UseSwagger() // .UseSwaggerUI(c => // { // c.SwaggerEndpoint("/swagger/v1/swagger.json", ".Net Core2 Api V1"); // }) // .UseMvcWithDefaultRoute(); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, IDbInitializer seeder) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseHsts(); } app.UseHttpsRedirection(); app.UseSwagger(); app.UseSwaggerUI(setupAction => { setupAction.SwaggerEndpoint(openApiSettings.GetSwaggerUrl(), openApiSettings.Name); }); app.UseMvc(); seeder.Seed().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, IDbInitializer dbInitializer, IServiceProvider serviceProvider) { loggerFactory.AddConsole(Configuration.GetSection("Logging")); loggerFactory.AddDebug(); if (env.IsDevelopment()) { app.UseBrowserLink(); app.UseDeveloperExceptionPage(); app.UseDatabaseErrorPage(); } else { app.UseExceptionHandler("/Error"); // For more details on creating database during deployment see http://go.microsoft.com/fwlink/?LinkID=615859 try { using (var serviceScope = app.ApplicationServices.GetRequiredService <IServiceScopeFactory>() .CreateScope()) { serviceScope.ServiceProvider.GetService <NocturnoContext>() .Database.Migrate(); } } catch { } } app.UseIISPlatformHandler(options => options.AuthenticationDescriptions.Clear()); app.UseStaticFiles(); app.UseIdentity(); // To configure external authentication please see http://go.microsoft.com/fwlink/?LinkID=532715 app.UseMvc(routes => { routes.MapRoute( name: "areaRoute", template: "{area:exists}/{controller=Home}/{action=Index}/{id?}"); routes.MapRoute( name: "default", template: "{name?}/{page?}", defaults: new { controller = "Master", action = "Index" }); //routes.MapRoute( // name: "default", // template: "{controller=Home}/{action=Index}/{id?}"); }); //dbInitializer.InitializeDatabaseAsync(); }
public HomeController(IDbInitializer dbInitializer) { this.dbInitializer = dbInitializer; var task = dbInitializer.Initialize(); task.Wait(); }
public DatabaseService(IDbInitializer dbInitializer) { _dbInitializer = dbInitializer; }
public ModuleEvents(IDbInitializer dbInitializer) { _dbInitializer = dbInitializer; }