114 lines
3.7 KiB
C#
114 lines
3.7 KiB
C#
using Blazorise;
|
|
using Blazorise.Bootstrap;
|
|
using Blazorise.Icons.FontAwesome;
|
|
using ElmahCore.Mvc;
|
|
using BlaServApp.UI.Data;
|
|
using Microsoft.AspNetCore.Builder;
|
|
using Microsoft.AspNetCore.Hosting;
|
|
using Microsoft.AspNetCore.Localization;
|
|
using Microsoft.Extensions.Configuration;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using Microsoft.Extensions.Hosting;
|
|
using System.Globalization;
|
|
|
|
namespace BlaServApp.UI
|
|
{
|
|
public class Startup
|
|
{
|
|
#region Public Constructors
|
|
|
|
public Startup(IConfiguration configuration)
|
|
{
|
|
Configuration = configuration;
|
|
}
|
|
|
|
#endregion Public Constructors
|
|
|
|
#region Public Properties
|
|
|
|
public IConfiguration Configuration { get; }
|
|
|
|
#endregion Public Properties
|
|
|
|
#region Public Methods
|
|
|
|
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
|
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
|
|
{
|
|
if (env.IsDevelopment())
|
|
{
|
|
app.UseDeveloperExceptionPage();
|
|
}
|
|
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();
|
|
}
|
|
|
|
// 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");
|
|
|
|
// Registrazione Elmah:
|
|
// https://github.com/ElmahCore/ElmahCore
|
|
app.UseElmah();
|
|
|
|
app.UseHttpsRedirection();
|
|
app.UseStaticFiles();
|
|
|
|
app.UseRouting();
|
|
|
|
app.UseEndpoints(endpoints =>
|
|
{
|
|
endpoints.MapBlazorHub();
|
|
endpoints.MapFallbackToPage("/_Host");
|
|
});
|
|
}
|
|
|
|
// This method gets called by the runtime. Use this method to add services to the container.
|
|
// For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
|
|
public void ConfigureServices(IServiceCollection services)
|
|
{
|
|
services.AddBlazorise(options =>
|
|
{
|
|
options.ChangeTextOnKeyPress = true; // optional
|
|
})
|
|
.AddBootstrapProviders()
|
|
.AddFontAwesomeIcons();
|
|
|
|
// Elmah
|
|
services.AddElmah();
|
|
//string elmaConn = "Data Source=SQL2016DEV;Initial Catalog=Elmah;User ID=sa;Password=keyhammer16;integrated security=False;MultipleActiveResultSets=True;App=SHERPA.BBM;";
|
|
//services.AddElmah<SqlErrorLog>(options =>
|
|
//{
|
|
// options.ConnectionString = elmaConn;
|
|
//});
|
|
|
|
services.AddStackExchangeRedisCache(options =>
|
|
{
|
|
options.Configuration = "localhost:6379";
|
|
});
|
|
|
|
services.AddLocalization();
|
|
|
|
services.AddRazorPages();
|
|
services.AddServerSideBlazor();
|
|
services.AddSingleton<IConfiguration>(Configuration);
|
|
//services.AddTransient<Services.BlazorTimer>();
|
|
|
|
//services.AddSingleton<MpStatsService>();
|
|
services.AddScoped<MessageService>();
|
|
}
|
|
|
|
#endregion Public Methods
|
|
}
|
|
} |