using Microsoft.AspNetCore.Identity; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.DependencyInjection; using rgbc_sds.dal.DB; using rgbc_sds.services.Models; using rgbc_sds.services.Services; var builder = WebApplication.CreateBuilder(args); var connectionString = builder.Configuration.GetConnectionString("rgbc_sdsContext"); builder.Services.AddDbContext(options => { options.UseSqlServer(connectionString); }); // Add logging builder.Logging.ClearProviders(); builder.Logging.AddConsole(); builder.Logging.AddDebug(); // Add services to the container. builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddControllersWithViews(); builder.Services.AddRazorPages().AddRazorRuntimeCompilation(); builder.Services.AddSession(options => { options.IdleTimeout = TimeSpan.FromMinutes(10); options.Cookie.HttpOnly = true; options.Cookie.IsEssential = true; }); builder.Services.AddSession(); #region [CORS] builder.Services.AddCors(options => { options.AddPolicy("CorsPolicy" , builder => builder.AllowAnyOrigin() .AllowAnyMethod() .AllowAnyHeader()); }); #endregion [CORS] var app = builder.Build(); // Configure the HTTP request pipeline. if (!app.Environment.IsDevelopment()) { app.UseExceptionHandler("/Home/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(); } else { app.UseDeveloperExceptionPage(); } app.UseHttpsRedirection(); app.UseStaticFiles(); app.UseRouting(); app.UseAuthorization(); app.MapRazorPages(); app.UseSession(); //app.MapControllerRoute( // name: "default", // pattern: "{controller=Account}/{action=Login}/{id?}"); app.MapControllerRoute(name: "login", pattern: "account/login", defaults: new { controller = "Account", action = "Login" }); app.MapControllers(); app.Run();