Ejemplo n.º 1
0
        public static IApplicationBuilder ConfigureTelemetry(this IApplicationBuilder app)
        {
            var initializer = new ArticleNotFoundInitializer();

            var configuration = app.ApplicationServices.GetService <TelemetryConfiguration>();

            configuration.TelemetryInitializers.Add(initializer);

            return(app);
        }
Ejemplo n.º 2
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, IOptionsSnapshot <AppSettings> settings)
        {
            var initializer = new ArticleNotFoundInitializer();

            // var configuration = app.ApplicationServices.GetService<TelemetryConfiguration>();
            // configuration.TelemetryInitializers.Add(initializer);


            if (env.IsDevelopment())
            {
                //app.UseBrowserLink();
                app.UseDeveloperExceptionPage();
                app.UseDatabaseErrorPage();
            }
            else
            {
                app.UseExceptionHandler("/Error");
                // app.UseHsts();
            }

            app.UseHsts(options => options.MaxAge(days: 365).IncludeSubdomains());
            app.UseXContentTypeOptions();
            app.UseReferrerPolicy(options => options.NoReferrer());
            app.UseXXssProtection(options => options.EnabledWithBlockMode());
            app.UseXfo(options => options.Deny());


            var supportedCultures = new[]
            {
                new CultureInfo("en"),
                new CultureInfo("sv"),
                new CultureInfo("es")
            };


            // var locOptions = app.ApplicationServices.GetService<IOptions<RequestLocalizationOptions>>();
            app.UseRequestLocalization(new RequestLocalizationOptions
            {
                DefaultRequestCulture = new RequestCulture("en"),
                // Formatting numbers, dates, etc
                SupportedCultures = supportedCultures,
                // UI strings that we have localized
                SupportedUICultures = supportedCultures
            });

            app.UseHttpsRedirection();
            app.UseStaticFiles();
            app.UseCookiePolicy();

            app.UseAuthentication();


            app.UseRSSFeed("/articles/feed", new Snickler.RSSCore.Models.RSSFeedOptions
            {
                Title       = "Odin CM Suggestion Feed",
                Copyright   = DateTime.UtcNow.Year.ToString(),
                Description = "RSS Feed for Odin CM",
                Url         = settings.Value.Url
            });


            var scope = app.ApplicationServices.CreateScope();

            var identityContext = scope.SeedData()
                                  .ServiceProvider
                                  .GetService <CoreOdinIdentityContext>();


            app.UseStatusCodePagesWithReExecute("/HttpErrors/{0}");

            app.UseMvc();


            CoreOdinIdentityContext.SeedData(identityContext);
        }