66 lines
1.9 KiB
C#
66 lines
1.9 KiB
C#
using Lux.Report.Server.Components;
|
|
using Microsoft.Extensions.FileProviders;
|
|
using NLog;
|
|
using NLog.Targets;
|
|
using NLog.Web;
|
|
|
|
var builder = WebApplication.CreateBuilder(args);
|
|
|
|
// recupero env corrente
|
|
var env = builder.Environment;
|
|
|
|
var logger = LogManager.Setup()
|
|
.LoadConfigurationFromAppSettings()
|
|
.GetCurrentClassLogger();
|
|
|
|
ConfigurationManager configuration = builder.Configuration;
|
|
logger.Info("Lux.Report.Manager | Program.cs: startup");
|
|
logger.Info($"Current ASPNETCORE_ENVIRONMENT: {env.EnvironmentName}");
|
|
|
|
// Add services to the container.
|
|
builder.Services.AddRazorComponents()
|
|
.AddInteractiveServerComponents();
|
|
|
|
var app = builder.Build();
|
|
|
|
// 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();
|
|
|
|
// 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<App>()
|
|
.AddInteractiveServerRenderMode();
|
|
|
|
app.Run();
|