// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, CRSDbContext context, RoleManager <ApplicationRole> roleManager, UserManager <ApplicationUser> 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.UseCors(bulider => bulider.WithOrigins(Configuration["JWTSettings:Client_URL"].ToString()) .AllowAnyMethod() .AllowAnyHeader()); app.UseHttpsRedirection(); UserInitializer.Initialize(context, userManager, roleManager).Wait(); TypeOfCustomerInitializer.Initialize(context).Wait(); CarModelInitializer.Initialize(context).Wait(); app.UseAuthentication(); app.UseMiddleware(typeof(ErrorHandlingMiddleware)); app.UseMvc(routes => { routes.MapRoute( name: "default", template: "{controller}/{action=Index}/{id?}"); }); }
public static void Main(string[] args) { var host = BuildWebHost(args); using (var scope = host.Services.CreateScope()) { var services = scope.ServiceProvider; //try //{ var context = services.GetRequiredService <ApplicationDbContext>(); LocationsInitializer.Initialize(context); GirosInitializer.Initialize(context); UserInitializer.Initialize(context); //} //catch (Exception ex) //{ // var logger = services.GetRequiredService<ILogger<Program>>(); // logger.LogError(ex, "Ha ocurrido un error al sembrar la base de datos."); //} } host.Run(); }