zotan.pw-web/Backend/Startup.cs

42 lines
1 KiB
C#
Raw Normal View History

2022-11-20 03:06:41 +01:00
using LinqToDB.Data;
2022-11-20 18:25:33 +01:00
using Microsoft.AspNetCore.StaticFiles;
2022-11-26 13:23:58 +01:00
using zotanpw.Backend;
using zotanpw.Backend.database;
2022-11-20 03:06:41 +01:00
DataConnection.DefaultSettings = new Database.Settings();
Migrations.RunMigrations();
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddRazorPages();
builder.Services.AddSession(options => {
options.IdleTimeout = TimeSpan.MaxValue;
options.Cookie.HttpOnly = true;
options.Cookie.IsEssential = true;
});
#if (DEBUG)
builder.Services.AddControllers().AddRazorRuntimeCompilation();
builder.Services.AddControllers();
#else
builder.Services.AddControllers();
#endif
var app = builder.Build();
if (!app.Environment.IsDevelopment()) {
app.UseExceptionHandler("/error");
app.UseHsts();
}
2022-11-20 18:25:33 +01:00
var provider = new FileExtensionContentTypeProvider { Mappings = { [".gpg"] = "application/pgp-signature" } };
app.UseStaticFiles(new StaticFileOptions { ContentTypeProvider = provider });
2022-11-20 03:06:41 +01:00
app.UseSession();
app.UseRouting();
app.UseAuthorization();
app.MapRazorPages();
app.MapControllers();
2022-11-20 22:26:21 +01:00
app.Run();