Esempio n. 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, FreelancerBlogContextSeedData seeder)
        {
            loggerFactory.AddConsole(Configuration.GetSection("Logging"));
            loggerFactory.AddDebug();

            if (env.IsDevelopment())
            {
                app.UseAspNetCoreExceptionHandler();
            }
            else
            {
                app.UseAspNetCoreExceptionHandler();
                app.UseStatusCodePagesWithRedirects("/Error/Status/{0}");
            }

            app.UseStaticFiles();

            app.UseAuthentication();

            app.UseSession();

            var supportedCultures = new[]
            {
                new CultureInfo("fa-IR"),
                new CultureInfo("en-US")
            };

            app.UseRequestLocalization(new RequestLocalizationOptions
            {
                DefaultRequestCulture = new RequestCulture(culture: "en-US", uiCulture: "en-US"),
                // Formatting numbers, dates, etc.
                SupportedCultures = supportedCultures,
                // UI strings that we have localized.
                SupportedUICultures = supportedCultures
            });

            app.UseMvcJQueryDataTables();

            app.UseMvc(routes =>
            {
                routes.MapRoute(name: "AreaRoute",
                                template: "{area:exists}/{controller}/{action}/{id?}/{title?}",
                                defaults: new { controller = "Home", action = "Index" });

                routes.MapRoute(
                    name: "default",
                    template: "{controller=Home}/{action=Index}/{id?}/{title?}");
            });

            seeder.SeedAdminUser();
        }
Esempio n. 2
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerFactory loggerFactory, FreelancerBlogContextSeedData seeder)
        {
            if (env.IsDevelopment())
            {
                app.UseAspNetCoreExceptionHandler();
            }
            else
            {
                app.UseAspNetCoreExceptionHandler();
                app.UseStatusCodePagesWithRedirects("/Error/Status/{0}");
            }

            app.UseStaticFiles();

            app.UseAuthentication();
            app.UseAuthorization();

            app.UseSession();

            var supportedCultures = new[]
            {
                new CultureInfo("fa-IR"),
                new CultureInfo("en-US")
            };

            app.UseRequestLocalization(new RequestLocalizationOptions
            {
                DefaultRequestCulture = new RequestCulture(culture: "en-US", uiCulture: "en-US"),
                // Formatting numbers, dates, etc.
                SupportedCultures = supportedCultures,
                // UI strings that we have localized.
                SupportedUICultures = supportedCultures
            });

            app.UseMvcJQueryDataTables();

            app.UseMvc(routes =>
            {
                routes.MapRoute("AreaRoute", "{area:exists}/{controller=Home}/{action=Index}/{id?}/{title?}");
                routes.MapRoute("default", "{controller=Home}/{action=Index}/{id?}/{title?}");
            });

            //app.UseEndpoints(endpoints =>
            //{
            //    endpoints.MapHub<ChatHub>("/chat");
            //    endpoints.MapControllerRoute("default", "{controller=Home}/{action=Index}/{id?}");
            //});

            seeder.SeedAdminUser().GetAwaiter().GetResult();
        }