// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ApplicationDbContext context, RoleManager <AppRole> roleManager, UserManager <AppUser> userManager) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } // global cors policy app.UseCors(x => x .AllowAnyOrigin() .AllowAnyMethod() .AllowAnyHeader()); app.UseHttpsRedirection(); app.UseRouting(); app.UseAuthentication(); app.UseAuthorization(); // seeding database if not available default values DbSeeder.SeedDb(context, roleManager); DbSeeder.SeedUsers(userManager); 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, UserManager <IdentityUser> userManager, RoleManager <IdentityRole> roleManager) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); app.UseDatabaseErrorPage(); } else { app.UseExceptionHandler("/Home/Error"); app.UseHsts(); } app.UseHttpsRedirection(); app.UseStaticFiles(); app.UseCookiePolicy(); app.UseAuthentication(); DbSeeder.SeedDb(userManager, roleManager); app.UseMvc(routes => { routes.MapRoute( name: "default", template: "{controller=Post}/{action=PostList}/{id?}"); }); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, ApplicationDbContext context, UserManager <ApplicationUser> userManager) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseExceptionHandler("/Error/500"); app.UseStatusCodePagesWithReExecute("/Error/{0}"); app.UseHsts(); } var options = new RewriteOptions() .AddRedirectToHttps(); app.UseRewriter(options); app.UseHttpsRedirection(); app.UseStaticFiles(); app.UseCookiePolicy(); app.UseAuthentication(); app.UseMvc(routes => { routes.MapRoute( name: "default", template: "{controller=Home}/{action=Index}/{id?}"); }); DbSeeder.SeedDb(context, userManager); }
// 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, IServiceProvider serviceProvider, ApplicationDbContext context, UserManager <ApplicationUser> userManager, RoleManager <ApplicationRole> roleManager) { app.UseResponseCompression(); 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(); } app.UseHttpsRedirection(); app.UseBlazorFrameworkFiles(); app.UseStaticFiles(); app.UseRouting(); app.UseAuthentication(); app.UseAuthorization(); DbSeeder.SeedDb(context, userManager, roleManager); app.UseEndpoints(endpoints => { 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, IWebHostEnvironment env, ApplicationDbContext context, UserManager <IdentityUser> userManager, RoleManager <IdentityRole> roleManager) { 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(); } app.UseHttpsRedirection(); app.UseStaticFiles(); app.UseRouting(); app.UseAuthentication(); app.UseAuthorization(); DbSeeder.SeedDb(context, userManager, roleManager).Wait(); 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, ApplicationDbContext context, UserManager <User> userManager, RoleManager <Role> roleManager, ILoggerFactory loggerFactory) { loggerFactory.AddConsole(LogLevel.Debug); loggerFactory.AddDebug(LogLevel.Debug); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); app.UseDatabaseErrorPage(); } else { app.UseExceptionHandler("/Home/Error"); app.UseHsts(); } app.UseHttpsRedirection(); app.UseStaticFiles(); app.UseCookiePolicy(); app.UseAuthentication(); DbSeeder.SeedDb(context, userManager, roleManager); 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, IHostingEnvironment env, TicketDBContext context) { // global cors policy app.UseCors(x => x .AllowAnyOrigin() .AllowAnyMethod() .AllowAnyHeader()); app.UseAuthentication(); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseHsts(); } app.UseHttpsRedirection(); //seed dataların yüklendiği kısım DbSeeder.SeedDb(context); 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, EventosApiContext context) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseHsts(); } app.UseCors("CorsPolicy"); app.UseHttpsRedirection(); app.UseStaticFiles(); DbSeeder.SeedDb(context); app.UseMvc(routes => { routes.MapRoute( name: "default", template: "{controller}/{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, ToDoContext toDoContext) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); DbSeeder.SeedDb(toDoContext); } else { app.UseHsts(); } Mapper.Initialize(cfg => { cfg.CreateMap <ToDo, ToDoDto>().ForMember(dest => dest.Status, opt => opt.MapFrom(src => src.GetStatus())) .ForMember(dest => dest.Time, opt => opt.MapFrom( src => src.GetTime())) .ForMember(dest => dest.Created, opt => opt.MapFrom( src => src.CreatedAtConverter())) .ForMember(dest => dest.Updated, opt => opt.MapFrom( src => src.UpdatedAtConverter())) .ForMember(dest => dest.Priority, opt => opt.MapFrom( src => src.PriorityName())); }); app.UseHttpsRedirection(); 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, DbSeeder seeder) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseAuthentication(); app.UseCors("AllowAll"); app.UseMvc(); seeder.SeedDb(); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, DbSeeder seeder) { app.UseMiddleware(typeof(ErrorHandlingMiddleware)); app.UseRouting(); app.UseCors("AllowAll"); app.UseAuthentication(); app.UseAuthorization(); app.UseEndpoints(endpoints => { endpoints.MapControllers(); }); seeder.SeedDb(); }
public void Configure(IApplicationBuilder app, IHostingEnvironment env, DemoDbContext dbContext) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseHsts(); } DbSeeder.SeedDb(dbContext); app.UseHttpsRedirection(); 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, StudentsDbContext context) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); DbSeeder.SeedDb(context); } app.UseHttpsRedirection(); app.UseMvc(); //app.Run(async (context) => //{ // await context.Response.WriteAsync("Hello World!"); //}); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, FinnAirContext context, IOptions <WebServerUrl> webServerSettings, ILoggerFactory loggerFactory, UserManager <IdentityUser> userManager) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { // 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.UseAuthentication(); //var swaggerOptions = new SwaggerOptions(); //Configuration.GetSection(nameof(SwaggerOptions)).Bind(swaggerOptions); app.UseSwagger(); //app.UseSwaggerUI(option => { // option.SwaggerEndpoint(swaggerOptions.UIEndpoint, swaggerOptions.Description); //}); var virtualDir = ""; if (!env.IsDevelopment()) { var webServerUrl = webServerSettings.Value; virtualDir = webServerUrl.AppVirtualDir; } app.UseSwaggerUI(option => { option.DocumentTitle = $"FinnAir API ({_apiVersion}) documentation"; option.SwaggerEndpoint(virtualDir + $"/swagger/{_apiVersion}/swagger.json", $"FinnAir API ({_apiVersion})"); }); DbSeeder.SeedDb(userManager); loggerFactory.AddFile("Logs/mylog-{Date}.txt"); app.UseMvc(); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ApplicationDbContext applicationDbContext) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseExceptionHandler(builder => { builder.Run(async context => { context.Response.StatusCode = (int)HttpStatusCode.InternalServerError; var error = context.Features.Get <IExceptionHandlerFeature>(); if (error != null) { await context.Response.WriteAsync(error.Error.Message); } }); }); } DbSeeder.SeedDb(applicationDbContext); app.UseCors(x => x.AllowAnyOrigin().AllowAnyMethod().AllowAnyHeader()); app.UseAuthentication(); app.UseRouting(); app.UseAuthorization(); // Make sure database is created and migrated. using (var serviceScope = app.ApplicationServices.GetService <IServiceScopeFactory>().CreateScope()) { var context = serviceScope.ServiceProvider.GetRequiredService <ApplicationDbContext>(); context.Database.Migrate(); } // Add endpoints to the request pipeline app.UseEndpoints(endpoints => { endpoints.MapControllers(); }); }
public void Configure(IApplicationBuilder app, IHostingEnvironment env, DemoDbContext dbContext) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseHsts(); } DbSeeder.SeedDb(dbContext); app.UseHttpsRedirection(); app.UseRouting(); app.UseEndpoints(endpoints => { endpoints.MapControllers(); }); }
public static async Task Main(string[] args) { //CreateHostBuilder(args).Build().Run(); var host = BuildWebHost(args); using (var scope = host.Services.CreateScope()) { var services = scope.ServiceProvider; try { var userManager = services.GetRequiredService <UserManager <UserProfile> >(); var rolesManager = services.GetRequiredService <RoleManager <IdentityRole> >(); await DbSeeder.SeedDb(userManager, rolesManager); } catch (Exception ex) { var logger = services.GetRequiredService <ILogger <Program> >(); logger.LogError(ex, "An error occurred while seeding the database."); } } host.Run(); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ApplicationDbContext context, UserManager <ApplicationUser> userManager) { 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(); } app.UseHttpsRedirection(); // Initialise ReactJS.NET. Must be before static files. app.UseReact(config => { // If you want to use server-side rendering of React components, // add all the necessary JavaScript files here. This includes // your components as well as all of their dependencies. // See http://reactjs.net/ for more information. Example: //config // .AddScript("~/js/First.jsx") // .AddScript("~/js/Second.jsx"); // If you use an external build too (for example, Babel, Webpack, // Browserify or Gulp), you can improve performance by disabling // ReactJS.NET's version of Babel and loading the pre-transpiled // scripts. Example: //config // .SetLoadBabel(false) // .AddScriptWithoutTransform("~/js/bundle.server.js"); }); app.UseStaticFiles(); app.UseSpaStaticFiles(); app.UseRouting(); app.UseAuthentication(); app.UseIdentityServer(); app.UseAuthorization(); DbSeeder.SeedDb(context, userManager); app.UseEndpoints(endpoints => { endpoints.MapControllerRoute( name: "default", pattern: "{controller}/{action=Index}/{id?}"); endpoints.MapRazorPages(); }); app.UseSpa(spa => { spa.Options.SourcePath = "ClientApp"; if (env.IsDevelopment()) { spa.UseReactDevelopmentServer(npmScript: "start"); } }); }