Esempio n. 1
0
        public void Configure(IApplicationBuilder app, IHostingEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                app.UseBrowserLink();
                app.UseDatabaseErrorPage();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
            }

            var appSettings = Configuration.GetSection("AppSettings").Get <AppSettings>();

            var cultureInfos = appSettings.SupportedLanguages
                               .Select(fourLettersIsoLanguage => new CultureInfo(fourLettersIsoLanguage))
                               .ToArray();

            app.UseRequestLocalization(new RequestLocalizationOptions
            {
                DefaultRequestCulture = new RequestCulture(appSettings.SupportedLanguages.First()),
                SupportedCultures     = cultureInfos,
                SupportedUICultures   = cultureInfos
            });

            app.UseStaticFiles();

            app.UseAuthentication();

            app.UseMvcWithDefaultRoute();

            //TODO: comment this part of code after seeding
            var serviceScopeFactory = app.ApplicationServices.GetRequiredService <IServiceScopeFactory>();

            using (var serviceScope = serviceScopeFactory.CreateScope())
            {
                ApplicationDbContextSeed.InitializeAdminsAsync(serviceScope).Wait();
            }
        }