Porting a versione 8 della struttura app x SPEC

This commit is contained in:
Samuele Locatelli
2026-05-26 17:49:32 +02:00
parent a94e40a6aa
commit 1cefa18895
25 changed files with 97 additions and 242 deletions
+18 -40
View File
@@ -1,10 +1,6 @@
using Microsoft.AspNetCore.Authentication.Negotiate;
using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components.Web;
using Microsoft.AspNetCore.StaticFiles;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.FileProviders;
using Microsoft.JSInterop;
using MP.AppAuth.Services;
using MP.Data.Services;
using MP.SPEC.Components;
@@ -12,7 +8,6 @@ using MP.SPEC.Data;
using MP.SPEC.Services;
using NLog;
using NLog.Targets;
using NLog.Targets.OpenTelemetryProtocol;
using NLog.Web;
using OpenTelemetry.Resources;
using OpenTelemetry.Trace;
@@ -21,14 +16,6 @@ using StackExchange.Redis;
var builder = WebApplication.CreateBuilder(args);
/*--------------------
* Note migrazione startup.cs --> program.cs:
*
* - https://stackoverflow.com/questions/69722872/asp-net-core-6-how-to-access-ConfMan-during-startup
* - https://docs.microsoft.com/en-us/aspnet/core/migration/50-to-60?view=aspnetcore-5.0&tabs=visual-studio#where-do-i-put-state-that-was-stored-as-fields-in-my-program-or-startup-class
*
* */
ConfigurationManager configuration = builder.Configuration;
var logger = LogManager.Setup()
@@ -141,10 +128,13 @@ builder.Services.AddAuthorization(options =>
options.FallbackPolicy = options.DefaultPolicy;
});
// redis replliminare
//setup Blazor
builder.Services.AddRazorComponents()
.AddInteractiveServerComponents();
// redis preliminare
builder.Services.AddSingleton<IConnectionMultiplexer>(redisMultiplexer);
builder.Services.AddRazorPages();
builder.Services.AddServerSideBlazor();
builder.Services.AddSingleton<MpDataService>();
builder.Services.AddSingleton<ListSelectDataSrv>();
builder.Services.AddSingleton<IOApiService>();
@@ -153,20 +143,10 @@ builder.Services.AddScoped<MsgServiceSpec>();
builder.Services.AddSingleton<SharedMemService>();
builder.Services.AddSingleton<TabDataService>();
builder.Services.AddSingleton<TabDataFeeder>();
#if false
builder.Services.AddBlazoredLocalStorage();
builder.Services.AddBlazoredSessionStorage();
#endif
// aggiunta helper local/session storage service
builder.Services.AddScoped<ISessionStorageService, SessionStorageService>();
builder.Services.AddScoped<ILocalStorageService, LocalStorageService>();
//builder.Services.AddScoped<SessionStorageService>();
//builder.Services.AddScoped<LocalStorageService>();
//builder.Services.AddScoped<ISessionStorageService>(sp =>
// new SessionStorageService(sp.GetRequiredService<IJSRuntime>()));
//builder.Services.AddScoped<ILocalStorageService>(sp =>
// new LocalStorageService(sp.GetRequiredService<IJSRuntime>()));
builder.Services.AddHttpClient();
@@ -179,7 +159,9 @@ logger.Info("Build App");
// aggiunt base URL x routing corretto
app.UsePathBase(configuration.GetValue<string>("SpecialConf:AppUrl"));
string baseUrl = configuration.GetValue<string>("SpecialConf:AppUrl") ?? "";
app.UsePathBase(baseUrl);
logger.Info($"BaseUrl: {baseUrl}");
// Configure the HTTP request pipeline.
if (!app.Environment.IsDevelopment())
@@ -193,6 +175,13 @@ app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseRouting();
app.UseAuthentication();
app.UseAuthorization();
app.UseAntiforgery();
// gestione static files: https://learn.microsoft.com/en-us/aspnet/core/fundamentals/static-files?view=aspnetcore-8.0
string BasePathOdlReturn = configuration.GetValue<string>("ServerConf:BasePathOdlReturn") ?? configuration.GetValue<string>("OptConf:BasePathOdlReturn") ?? "";
if (!string.IsNullOrEmpty(BasePathOdlReturn))
@@ -234,19 +223,8 @@ if (!string.IsNullOrEmpty(BasePathOdlReturn))
}
}
app.UseRouting();
app.UseAuthentication();
app.UseAuthorization();
app.UseEndpoints(endpoints =>
{
endpoints.MapControllers();
endpoints.MapBlazorHub();
endpoints.MapFallbackToPage("/_Host");
});
//app.MapBlazorHub();
//app.MapFallbackToPage("/_Host");
app.MapRazorComponents<App>()
.AddInteractiveServerRenderMode();
logger.Info("Run App");