public void Configure(IApplicationBuilder app, IWebHostEnvironment env, IRecurringJobManager recurringJobManager)
{
AutoMapperConfig.RegisterMappings(typeof(ErrorViewModel).GetTypeInfo().Assembly);
// Seed data on application startup
using (var serviceScope = app.ApplicationServices.CreateScope())
{
var dbContext = serviceScope.ServiceProvider.GetRequiredService<ApplicationDbContext>();
dbContext.Database.Migrate();
new ApplicationDbContextSeeder().SeedAsync(dbContext, serviceScope.ServiceProvider).GetAwaiter().GetResult();
}
this.SeedHangfireJobs(recurringJobManager);
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
app.UseMigrationsEndPoint();
}
else
{
app.UseExceptionHandler("/Home/Error");
app.UseHsts();
}
app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseCookiePolicy();
app.UseRouting();
app.UseAuthentication();
app.UseAuthorization();
if (env.IsProduction())
{
app.UseHangfireDashboard(
"/hangfire",
new DashboardOptions { Authorization = new[] { new HangfireAuthorizationFilter() } });
}
app.UseEndpoints(
endpoints =>
{
endpoints.MapControllerRoute(
"index.html",
"index.html",
new { controller = "Home", action = "Index" });
endpoints.MapControllerRoute(
"Blog post",
"Blog/{year}/{month}/{title}/{id}",
new { controller = "Blog", action = "Post" });
endpoints.MapControllerRoute(
"Page",
"Pages/{permalink}",
new { controller = "Pages", action = "Page" });
endpoints.MapControllerRoute(
"areaRoute",
"{area:exists}/{controller=Home}/{action=Index}/{id?}");
endpoints.MapControllerRoute("default", "{controller=Home}/{action=Index}/{id?}");
endpoints.MapRazorPages();
});
}