56 lines
1.5 KiB
C#
56 lines
1.5 KiB
C#
using AppLibs.Libs;
|
|
using Microsoft.AspNetCore.Http.Features;
|
|
using System.Net;
|
|
using System.Text;
|
|
using TWASys_App.Models.Login;
|
|
|
|
await WSNavigation.LoadJson();
|
|
var builder = WebApplication.CreateBuilder(args);
|
|
builder.Services.Configure<FormOptions>(o => {
|
|
o.MultipartBodyLengthLimit = 200_000_000; // 200 MB
|
|
});
|
|
builder.Services.AddControllers(options =>
|
|
{
|
|
options.Filters.Add(new LoginCheckFilter());
|
|
options.Filters.Add<AsyncGateAttribute>();
|
|
}).AddJsonOptions(options =>
|
|
{
|
|
options.JsonSerializerOptions.PropertyNamingPolicy = null;
|
|
options.JsonSerializerOptions.PropertyNameCaseInsensitive = true;
|
|
});
|
|
builder.Services.AddDistributedMemoryCache(); // IDistributedCache in-memory
|
|
builder.Services.AddSession(o =>
|
|
{
|
|
o.IdleTimeout = TimeSpan.FromHours(8);
|
|
o.Cookie.HttpOnly = true;
|
|
o.Cookie.IsEssential = true;
|
|
o.Cookie.SecurePolicy = CookieSecurePolicy.Always;
|
|
});
|
|
builder.Services.AddControllersWithViews().AddRazorRuntimeCompilation();
|
|
|
|
// Add services to the container.
|
|
|
|
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.UseRouting();
|
|
|
|
app.UseAuthorization();
|
|
|
|
app.MapStaticAssets();
|
|
app.UseSession();
|
|
app.MapControllerRoute(
|
|
name: "default",
|
|
pattern: "{controller=Home}/{action=Index}/{id?}")
|
|
.WithStaticAssets();
|
|
|
|
app.Run();
|