using ElmahCore.Mvc; 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 MP.Stats.Data; using System.Globalization; namespace MP.Stats { 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) { // 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(options => //{ // options.ConnectionString = elmaConn; //}); services.AddStackExchangeRedisCache(options => { //options.Configuration = "localhost:6379"; options.ConfigurationOptions = new StackExchange.Redis.ConfigurationOptions() { KeepAlive = 180, DefaultDatabase = 5, EndPoints = { { "localhost", 6379 } } }; options.InstanceName = "MP:Stats"; }); services.AddLocalization(); services.AddRazorPages(); services.AddServerSideBlazor(); services.AddSingleton(Configuration); services.AddSingleton(); services.AddScoped(); } #endregion Public Methods } }