Quantcast
Channel: ASP.NET Core
Viewing all articles
Browse latest Browse all 9386

route configuration

$
0
0

Hi,

I have 3 controllers. These are HomeController, PagesController and Categories. There are languages options. I want to create these url:

localhost:64629/

localhost:64629/AboutUs

localhost:64629/Categories/Books

localhost:64629/en-GB/

localhost:64629/en-GB/AboutUs

localhost:64629/en-GB/Categories/Books

how can  I create localization option dynamic. do I have create static for every language? these are ? 

localhost:64629/ru-RU/

localhost:64629/ru-RU/AboutUs

localhost:64629/ru-RU/Categories/Books

            app.UseMvc(routes =>
            {
                routes.MapRoute(
                name: "CategoryEnglish",
                template: "en-GB/Categories/{CategoryName}",
                defaults: new { controller = "Categories", action = "Category" },
                constraints: null,
                dataTokens: new { Name = "en-GB" });

                routes.MapRoute(
                name: "PagesEnglish",
                template: "en-GB/{PageName}",
                defaults: new { controller = "Pages", action = "Page" },
                constraints: null,
                dataTokens: new { Name = "en-GB" });

                routes.MapRoute(
                name: "DefaultEnglish",
                template: "en-GB/",
                defaults: new { controller = "Home", action = "Index" },
                constraints: null,
                dataTokens: new { Name = "en-GB" });

                routes.MapRoute(
                name: "Category",
                template: "Kategoriler/{CategoryName}",
                defaults: new { controller = "Categories", action = "Category" },
                constraints: null,
                dataTokens: new { Name = "tr-TR" });

                routes.MapRoute(
                name: "Pages",
                template: "{PageName}",
                defaults: new { controller = "Pages", action = "Page" },
                constraints: null,
                dataTokens: new { Name = "tr-TR" });

                routes.MapRoute(
                name: "Default",
                template: "",
                defaults: new { controller = "Home", action = "Index" },
                constraints: null,
                dataTokens: new { Name = "tr-TR" });
            });


Viewing all articles
Browse latest Browse all 9386

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>