oliverbooth.dev/OliverBooth/Program.cs

38 lines
1.1 KiB
C#
Raw Normal View History

2023-08-06 15:56:08 +01:00
using NLog.Extensions.Logging;
using OliverBooth.Data;
2023-08-06 15:56:08 +01:00
using OliverBooth.Services;
using X10D.Hosting.DependencyInjection;
WebApplicationBuilder builder = WebApplication.CreateBuilder(args);
builder.Configuration.AddTomlFile("data/config.toml", true, true);
2023-05-26 19:05:44 +01:00
2023-08-06 15:56:08 +01:00
builder.Logging.ClearProviders();
builder.Logging.AddNLog();
builder.Services.AddHostedSingleton<LoggingService>();
builder.Services.AddDbContextFactory<BlogContext>();
builder.Services.AddDbContextFactory<WebContext>();
2023-08-06 15:55:12 +01:00
builder.Services.AddRazorPages().AddRazorRuntimeCompilation();
2023-08-05 21:01:47 +01:00
builder.Services.AddControllersWithViews();
builder.Services.AddRouting(options => options.LowercaseUrls = true);
2023-05-26 19:05:44 +01:00
WebApplication app = builder.Build();
2023-05-26 19:05:44 +01:00
if (!app.Environment.IsDevelopment())
{
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.UseStaticFiles();
app.UseRouting();
app.UseAuthorization();
2023-08-05 20:58:03 +01:00
2023-08-05 21:01:47 +01:00
app.MapControllers();
app.MapControllerRoute("default", "{controller=Home}/{action=Index}/{id?}");
2023-05-26 19:05:44 +01:00
app.MapRazorPages();
app.Run();