// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env, IIdentityInitializer identityInitializer) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); var supportedCultures = new[] { new CultureInfo("en-US") }; app.UseRequestLocalization(new RequestLocalizationOptions { DefaultRequestCulture = new RequestCulture("en-US"), SupportedCultures = supportedCultures, SupportedUICultures = supportedCultures }); identityInitializer.SeedData().Wait(); } app.UseStatusCodePages(); app.UseStaticFiles(); app.UseSession(); app.UseRouting(); app.UseAuthentication(); app.UseAuthorization(); app.UseEndpoints(endpoint => { endpoint.MapControllerRoute( name: null, pattern: "{category}/Page{productPage:int}", defaults: new { controller = "Product", action = "List" }); endpoint.MapControllerRoute( name: null, pattern: "Page{productPage:int}", defaults: new { controller = "Product", action = "List", productPage = 1 }); endpoint.MapControllerRoute( name: null, pattern: "{category}", defaults: new { controller = "Product", action = "List", productPage = 1 }); endpoint.MapControllerRoute( name: null, pattern: "", defaults: new { controller = "Product", action = "List", productPage = 1 }); endpoint.MapControllerRoute( name: null, pattern: "{controller}/{action}/{id?}"); }); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, IIdentityInitializer identityInitializer) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); identityInitializer.SeedData(); } else { app.UseExceptionHandler("/Home/Error"); app.UseHsts(); } app.UseHttpsRedirection(); app.UseStaticFiles(); app.UseCookiePolicy(); app.UseSession(); app.UseMvc(routes => { routes.MapRoute(name: "Error", template: "Error", defaults: new { controller = "Error", action = "Error" }); routes.MapRoute( name: null, template: "{category}/Page{productPage:int}", defaults: new { controller = "Product", action = "List" } ); routes.MapRoute( name: null, template: "Page{productPage:int}", defaults: new { controller = "Product", action = "List", productPage = 1 } ); routes.MapRoute( name: null, template: "{category}", defaults: new { controller = "Product", action = "List", productPage = 1 } ); routes.MapRoute( name: null, template: "", defaults: new { controller = "Product", action = "List", productPage = 1 }); routes.MapRoute(name: null, template: "{controller}/{action}/{id?}"); }); }