示例#1
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILogger <Startup> logger)
        {
            if (env.IsDevelopment())
            {
                logger.LogInformation($"Hello from {nameof(Startup)} in {env.EnvironmentName} environment");
                app.UseDeveloperExceptionPage();
            }

            app.UseRouting();
            app.UseRouter(RouteHelper.GetRouterMiddleware(app));

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllerRoute(
                    name: "us_english_products",
                    pattern: "en-US/Products/{id}",
                    defaults: new { controller = "Products", action = "Details" },
                    constraints: new { id = new IntRouteConstraint() },
                    dataTokens: new { locale = "en-US" });
                endpoints.MapControllerRoute(
                    "default",
                    "{controller=Home}/{action=Index}/{id?}");
            });
        }