From a440be4df759c7d317c1574ce1132fab807494f2 Mon Sep 17 00:00:00 2001 From: Jake Mannens Date: Sun, 17 Sep 2023 22:51:50 +1000 Subject: Consolidated user session state and made it persistent across all scopes pertaining to a session --- Program.cs | 3 +++ 1 file changed, 3 insertions(+) (limited to 'Program.cs') diff --git a/Program.cs b/Program.cs index e78f0d4..79fe8fa 100644 --- a/Program.cs +++ b/Program.cs @@ -8,6 +8,7 @@ namespace HyperBooru; public class Program { public static void Main(string[] args) { var builder = WebApplication.CreateBuilder(args); + builder.Services.AddSession(); builder.Services.AddHttpContextAccessor(); builder.Services.AddAuthentication( CookieAuthenticationDefaults.AuthenticationScheme).AddCookie(); @@ -24,6 +25,7 @@ public class Program { builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); + builder.Services.AddSingleton(); builder.Services.AddScoped(); builder.Services.AddHostedService(); @@ -34,6 +36,7 @@ public class Program { using var db = scope.ServiceProvider.GetRequiredService(); db.Database.Migrate(); + app.UseSession(); app.UseHsts(); app.UseHttpsRedirection(); app.UseStaticFiles(); -- cgit v1.3