2022-09-26 04:05:23 +03:00
|
|
|
using BlueWest.Views.Utils;
|
|
|
|
using System.Globalization;
|
|
|
|
using Microsoft.AspNetCore.Authentication.Cookies;
|
|
|
|
using Microsoft.AspNetCore.Localization;
|
|
|
|
using Microsoft.Extensions.Options;
|
|
|
|
|
|
|
|
|
2022-09-19 05:50:15 +03:00
|
|
|
var builder = WebApplication.CreateBuilder(args);
|
|
|
|
|
2022-09-26 04:05:23 +03:00
|
|
|
builder.Services.AddSingleton<LayoutCache>();
|
2022-09-19 05:50:15 +03:00
|
|
|
// Add services to the container.
|
2022-09-26 04:05:23 +03:00
|
|
|
|
|
|
|
builder.Services.Configure<CookiePolicyOptions>(options =>
|
|
|
|
{
|
|
|
|
// This lambda determines whether user consent for non-essential cookies is needed for a given request.
|
|
|
|
options.CheckConsentNeeded = context => true;
|
|
|
|
options.MinimumSameSitePolicy = SameSiteMode.None;
|
|
|
|
});
|
|
|
|
builder.Services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme)
|
|
|
|
.AddCookie(cookieOptions => {
|
|
|
|
cookieOptions.LoginPath = "/";
|
|
|
|
});
|
|
|
|
|
2022-09-19 05:50:15 +03:00
|
|
|
builder.Services.AddControllersWithViews();
|
|
|
|
|
|
|
|
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();
|
|
|
|
}
|
|
|
|
|
|
|
|
app.UseHttpsRedirection();
|
|
|
|
app.UseStaticFiles();
|
|
|
|
|
|
|
|
app.UseRouting();
|
|
|
|
|
2022-09-26 04:05:23 +03:00
|
|
|
app.UseRequestLocalization(options =>
|
|
|
|
{
|
|
|
|
var supportedCultures = CultureInfo.GetCultures(CultureTypes.AllCultures);
|
|
|
|
options.DefaultRequestCulture = new RequestCulture("en-GB");
|
|
|
|
options.SupportedCultures = supportedCultures;
|
|
|
|
options.SupportedUICultures = supportedCultures;
|
|
|
|
});
|
|
|
|
|
2022-09-19 05:50:15 +03:00
|
|
|
app.UseAuthorization();
|
|
|
|
|
|
|
|
app.MapControllerRoute(
|
|
|
|
name: "default",
|
|
|
|
pattern: "{controller=Home}/{action=Index}/{id?}");
|
|
|
|
|
|
|
|
app.Run();
|