using MP.Data.Services; using MP.MON.Components; using NLog; using NLog.Web; using StackExchange.Redis; var builder = WebApplication.CreateBuilder(args); // Add services to the container. builder.Services.AddRazorComponents() .AddInteractiveServerComponents() .AddInteractiveWebAssemblyComponents(); var logger = LogManager.Setup() .LoadConfigurationFromAppSettings() .GetCurrentClassLogger(); logger.Info("Program.cs: startup"); ConfigurationManager configuration = builder.Configuration; // REDIS setup logger.Info("Setup REDIS"); string connStringRedis = configuration.GetConnectionString("Redis") ?? "localhost:6379"; string redisSrvAddr = connStringRedis.Substring(0, connStringRedis.IndexOf(":")); // avvio oggetto shared x redis... var redisMultiplexer = ConnectionMultiplexer.Connect(connStringRedis); // Add services to the container. logger.Info("Setup Services"); builder.Services.AddSingleton(redisMultiplexer); builder.Services.AddSingleton(); var app = builder.Build(); // Configure the HTTP request pipeline. if (app.Environment.IsDevelopment()) { app.UseWebAssemblyDebugging(); } else { app.UseExceptionHandler("/Error", createScopeForErrors: true); // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. app.UseHsts(); } string basePath = configuration.GetValue("ServerConf:BaseAppPath") ?? "/"; app.UsePathBase(basePath); logger.Info($"Base application path: {basePath}"); app.UseHttpsRedirection(); app.UseStaticFiles(); app.UseAntiforgery(); app.MapRazorComponents() .AddInteractiveServerRenderMode() .AddInteractiveWebAssemblyRenderMode() .AddAdditionalAssemblies(typeof(MP.MON.Client._Imports).Assembly); logger.Info("App: Run stage"); app.Run();