51 lines
1.5 KiB
C#
51 lines
1.5 KiB
C#
using MP_TAB.Components;
|
|
using MP.Data.Services;
|
|
using StackExchange.Redis;
|
|
|
|
var builder = WebApplication.CreateBuilder(args);
|
|
ConfigurationManager configuration = builder.Configuration;
|
|
// REDIS setup
|
|
var cString = configuration.GetConnectionString("Redis");
|
|
string connStringRedis = cString ?? "localhost:6379, DefaultDatabase=1, connectTimeout=5000, syncTimeout=5000, asyncTimeout=5000, abortConnect=false, ssl=false";
|
|
//string redisSrvAddr = connStringRedis.Substring(0, connStringRedis.IndexOf(":"));
|
|
// avvio oggetto shared x redis...
|
|
var redisMultiplexer = ConnectionMultiplexer.Connect(connStringRedis);
|
|
|
|
// Add services x accesso dati
|
|
builder.Services.AddSingleton<IConnectionMultiplexer>(redisMultiplexer);
|
|
builder.Services.AddSingleton<StatusData>();
|
|
builder.Services.AddSingleton<MenuData>();
|
|
|
|
// nuova versione contenuti...
|
|
builder.Services.AddRazorComponents()
|
|
.AddServerComponents()
|
|
.AddWebAssemblyComponents();
|
|
|
|
var app = builder.Build();
|
|
|
|
// aggiunt base URL x routing corretto
|
|
app.UsePathBase(configuration["OptConf:BaseUrl"]);
|
|
app.UseAntiforgery();
|
|
|
|
// Configure the HTTP request pipeline.
|
|
if (app.Environment.IsDevelopment())
|
|
{
|
|
app.UseWebAssemblyDebugging();
|
|
}
|
|
else
|
|
{
|
|
app.UseExceptionHandler("/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.UseStaticFiles();
|
|
|
|
app.MapRazorComponents<App>()
|
|
.AddServerRenderMode()
|
|
.AddWebAssemblyRenderMode();
|
|
|
|
app.Run();
|