using Lux.Report.Server.Components; using Microsoft.AspNetCore.Localization; using Microsoft.Extensions.FileProviders; using NLog; using NLog.Targets; using NLog.Web; using System.Globalization; using System.Reflection; var builder = WebApplication.CreateBuilder(args); // recupero env corrente var env = builder.Environment; var logger = LogManager.Setup() .LoadConfigurationFromAppSettings() .GetCurrentClassLogger(); ConfigurationManager configuration = builder.Configuration; var assemblyVersion = Assembly.GetExecutingAssembly().GetName().Version?.ToString(); logger.Info($"Lux.Report.Server | Program.cs: startup | v.{assemblyVersion}"); logger.Info($"Current ASPNETCORE_ENVIRONMENT: {env.EnvironmentName}"); // Add services to the container. builder.Services.AddRazorComponents() .AddInteractiveServerComponents(); var app = builder.Build(); // aggiunt base URL x routing corretto string baseUrl = configuration.GetValue("ServerConf:BaseUrl") ?? ""; app.UsePathBase(baseUrl); logger.Info($"BaseUrl: {baseUrl}"); // Configure the HTTP request pipeline. if (!app.Environment.IsDevelopment()) { 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(); } app.UseHttpsRedirection(); app.UseStaticFiles(); app.UseAntiforgery(); // cultura IT... var supportedCultures = new[]{ new CultureInfo("it-IT") }; app.UseRequestLocalization(new RequestLocalizationOptions { DefaultRequestCulture = new RequestCulture("it-IT"), SupportedCultures = supportedCultures, FallBackToParentCultures = false }); CultureInfo.DefaultThreadCurrentCulture = CultureInfo.CreateSpecificCulture("it-IT"); // gestione fileshare x uploads: verifico da conf se sia linux o windows x file da accedere... if (configuration["ServerConf:HostOs"] == "Win") { app.UseFileServer(new FileServerOptions { FileProvider = new PhysicalFileProvider(@"\\stor01\TEAM DRIVES\40_FileUpload\LuxUploads"), RequestPath = new PathString("/unsafe_uploads"), EnableDirectoryBrowsing = true //EnableDirectoryBrowsing = false }); } else { app.UseFileServer(new FileServerOptions { FileProvider = new PhysicalFileProvider(Path.Combine(env.ContentRootPath, "unsafe_uploads")), RequestPath = new PathString("/unsafe_uploads"), EnableDirectoryBrowsing = true //EnableDirectoryBrowsing = false }); } app.MapRazorComponents() .AddInteractiveServerRenderMode(); app.Run();