using ConfigurationPannel.Services; using Microsoft.AspNetCore.Authentication.Cookies; using ConfigurationManager = ConfigurationPannel.Services.ConfigurationManager; var builder = WebApplication.CreateBuilder(args); // Add services to the container. builder.Services.AddRazorPages(); // Authentication builder.Services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme) .AddCookie(options => { options.LoginPath = "/Login"; options.LogoutPath = "/Logout"; options.ExpireTimeSpan = TimeSpan.FromHours(8); options.SlidingExpiration = true; }); builder.Services.AddAuthorization(); // Application services builder.Services.AddSingleton(); builder.Services.AddSingleton(); builder.Services.AddSingleton(); // PrintServer as hosted service builder.Services.AddHostedService(); // Make PrintServerHostedService available for injection (for restart capability) builder.Services.AddSingleton(sp => sp.GetServices() .OfType() .FirstOrDefault()!); var app = builder.Build(); // set port app.Urls.Add($"http://*:80"); // Configure the HTTP request pipeline. if (!app.Environment.IsDevelopment()) { app.UseExceptionHandler("/Error"); } app.UseStaticFiles(); app.UseRouting(); // Authentication & Authorization app.UseAuthentication(); app.UseAuthorization(); app.MapRazorPages(); app.Run();