Example #1
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
        {
            loggerFactory.AddConsole(Configuration.GetSection("Logging"));
            loggerFactory.AddDebug();
            loggerFactory.AddConsole();
            loggerFactory.AddTextFile(Path.Combine(Directory.GetCurrentDirectory(), "HookLog.txt"));
            //loggerFactory.AddAzureWebAppDiagnostics();

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

                // For more details on creating database during deployment see http://go.microsoft.com/fwlink/?LinkID=615859
                try
                {
                    using (var serviceScope = app.ApplicationServices.GetRequiredService <IServiceScopeFactory>()
                                              .CreateScope())
                    {
                        serviceScope.ServiceProvider.GetService <FCWebContext>()
                        .Database.Migrate();
                    }
                }
                catch { }
            }

            //app.UseIISPlatformHandler(options => options.AuthenticationDescriptions.Clear());

            app.UseImageProcessingMiddleware();
            app.UseResponseCaching();
            app.UseStaticFiles();
            app.UseIdentity();
            app.AddCoreConfiguration(Configuration);

            // To configure external authentication please see http://go.microsoft.com/fwlink/?LinkID=532715

            var requestLocalizationOptions = new RequestLocalizationOptions
            {
                // Set options here to change middleware behavior
                SupportedCultures = new List <CultureInfo>
                {
                    new CultureInfo("en-US"),
                    new CultureInfo("ru-RU")
                },
                SupportedUICultures = new List <CultureInfo>
                {
                    new CultureInfo("en-US"),
                    new CultureInfo("ru-RU")
                },
                DefaultRequestCulture = new RequestCulture("ru-RU")
            };

            app.UseRequestLocalization(requestLocalizationOptions);

            app.Use((context, next) =>
            {
                if (context.Features.Get <IResponseCachingFeature>() == null)
                {
                    context.Features.Set <IResponseCachingFeature>(new FakeResponseCachingFeature());
                }
                return(next());
            });

            app.UseMvc(routes =>
            {
                routes
                .MapRoute(
                    name: "logoff",
                    template: "account/logoff",
                    defaults: new { controller = "account", action = "logoff" })
                .MapRoute(
                    name: "account",
                    template: "account/login",
                    defaults: new { controller = "account", action = "login" })
                .MapRoute(
                    name: "office",
                    template: "office/{*.}",
                    defaults: new { controller = "Office", action = "Index" })
                .MapRoute(
                    name: "default",
                    template: "{*.}",
                    defaults: new { controller = "Home", action = "Index" });
            });
        }