using CouponReport.Models.CouponMiddleware; using CouponReport.Models.Parkingeyes; using CouponReport.Service; using LaneFlowReport.Auth; using LaneFlowReport.Options; using Microsoft.AspNetCore.Authentication.Cookies; using Microsoft.EntityFrameworkCore; var builder = WebApplication.CreateBuilder(args); builder.Services.AddHttpClient(); builder.Services.AddScoped(); builder.Services.AddSingleton(); builder.Services.Configure(builder.Configuration.GetSection("Authentication:Parking")); builder.Services.AddDbContext(options => options.UseSqlServer(builder.Configuration.GetConnectionString("myConnection"))); builder.Services.AddDbContext(options => options.UseSqlServer(builder.Configuration.GetConnectionString("ParkingEyesConnection"))); builder.Services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme) .AddCookie(options => { options.LoginPath = "/Home/Index"; options.AccessDeniedPath = "/Home/Index"; options.Cookie.HttpOnly = true; options.Cookie.IsEssential = true; options.Cookie.SameSite = SameSiteMode.Strict; options.SlidingExpiration = true; options.Cookie.Expiration = null; }); // Add services to the container. builder.Services.AddControllersWithViews(); builder.Services.AddSession(options => { options.Cookie.HttpOnly = true; options.Cookie.IsEssential = true; }); var app = builder.Build(); // Configure the HTTP request pipeline. if (!app.Environment.IsDevelopment()) { app.UseExceptionHandler("/Home/Error"); app.UseHsts(); } app.UseHttpsRedirection(); app.UseStaticFiles(); app.UseRouting(); app.UseSession(); app.UseAuthentication(); app.UseAuthorization(); app.MapControllerRoute( name: "default", pattern: "{controller=Home}/{action=Index}/{id?}"); app.Run();