3173393e8d
- render mode in app.razor - reload in app.razro - update nuget - fix comportamento pagina DayOff - cleanup generale
94 lines
3.0 KiB
C#
94 lines
3.0 KiB
C#
using Blazored.LocalStorage;
|
|
using Blazored.SessionStorage;
|
|
using GPW.CORE.Data;
|
|
using GPW.CORE.Smart.Components;
|
|
using GPW.CORE.Smart.Data;
|
|
using Microsoft.AspNetCore.Identity.UI.Services;
|
|
using Microsoft.AspNetCore.Localization;
|
|
using StackExchange.Redis;
|
|
using System.Globalization;
|
|
|
|
var builder = WebApplication.CreateBuilder(args);
|
|
|
|
// Add services to the container.
|
|
builder.Services.AddRazorComponents()
|
|
.AddInteractiveServerComponents();
|
|
|
|
// configuration setup
|
|
ConfigurationManager configuration = builder.Configuration;
|
|
|
|
// REDIS setup
|
|
string connStringRedis = configuration.GetConnectionString("Redis")!;
|
|
string redisSrvAddr = connStringRedis.Substring(0, connStringRedis.IndexOf(":"));
|
|
// avvio oggetto shared x redis...
|
|
var redisMultiplexer = ConnectionMultiplexer.Connect(connStringRedis);
|
|
|
|
// abilitazione x email management con MailKit
|
|
builder.Services.AddTransient<IEmailSender, MailKitEmailSender>();
|
|
|
|
builder.Services.Configure<MailKitEmailSenderOptions>(options =>
|
|
{
|
|
options.Host_Address = configuration["ExternalProviders:MailKit:SMTP:Address"]!;
|
|
options.Host_Port = Convert.ToInt32(configuration["ExternalProviders:MailKit:SMTP:Port"]);
|
|
options.Host_Username = configuration["ExternalProviders:MailKit:SMTP:Account"]!;
|
|
options.Host_Password = configuration["ExternalProviders:MailKit:SMTP:Password"]!;
|
|
options.Sender_EMail = configuration["ExternalProviders:MailKit:SMTP:SenderEmail"]!;
|
|
options.Sender_Name = configuration["ExternalProviders:MailKit:SMTP:SenderName"]!;
|
|
});
|
|
|
|
// Add services to the container.
|
|
builder.Services.AddRazorPages();
|
|
builder.Services.AddServerSideBlazor();
|
|
builder.Services.AddSingleton<CoreSmartDataService>();
|
|
builder.Services.AddSingleton<LicenseService>();
|
|
builder.Services.AddSingleton<IConnectionMultiplexer>(redisMultiplexer);
|
|
builder.Services.AddScoped<MessageService>();
|
|
|
|
builder.Services.AddHttpContextAccessor();
|
|
|
|
builder.Services.AddBlazoredLocalStorage();
|
|
builder.Services.AddBlazoredSessionStorage();
|
|
|
|
var app = builder.Build();
|
|
|
|
// aggiunt base URL x routing corretto
|
|
app.UsePathBase(configuration.GetValue<string>("OptConf: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();
|
|
}
|
|
|
|
|
|
// 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");
|
|
|
|
app.UseHttpsRedirection();
|
|
|
|
app.UseStaticFiles();
|
|
app.UseAntiforgery();
|
|
|
|
app.MapRazorComponents<App>()
|
|
.AddInteractiveServerRenderMode();
|
|
|
|
//app.UseRouting();
|
|
|
|
// aggiunta x ApiController x IP discovery
|
|
app.MapControllers();
|
|
//app.MapBlazorHub();
|
|
//app.MapFallbackToPage("/_Host");
|
|
|
|
app.Run();
|