How should I implement localization with ASP.NET MVC routes?

浪尽此生 提交于 2019-12-01 09:14:59

I have exactly the same URL_mapping like you. My route also uses a constraint. Works for me.

   routes.MapRoute(
            // Route name
            "LocalizedController", 
            // URL with parameters                                             
            "{language}/{controller}/{action}",
            // Parameter defaults
            new {
                controller = "Home", action = "Index", 
                language = "de"
            },
              //Parameter constraints
            new { language = @"de|en" }
Andrei Rînea

I would use a different URL scheme like so :

en.mysite.com (English)
mysite.com (default language)
ro.mysite.com (Romanian)

etc.

Then I would create a custom route like in this answer.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!