ASP.NET MVC. How to suppress showing default culture in URL?

我怕爱的太早我们不能终老 提交于 2020-01-02 07:34:22

问题


here is question. I have an localized asp.net mvc website. Localization done by next steps: 1. for each route I automatically add an {culture} url segment with default value to "ru".

I want my urls to be with culture only for foreign cultures. For example:

http://mysite.com/ua/contacts - ukrainian
http://mysite.com/fr/contacts - francis
http://mysite.com/contacts - russian

I can't arrive this, because @Url.Action method always returns url with culture, even then it is a default culture. Help me please!


回答1:


 routes.MapRoute(
                "Default",                                              // Route name
                "{controller}/{action}/{id}",                           // URL with parameters
                new { controller = "Home", action = "Index", id = "" }  // Parameter defaults
            );

as base you can find solution right here
http://www.asp.net/mvc/tutorials/older-versions/controllers-and-routing/asp-net-mvc-routing-overview-cs and on msdn
http://msdn.microsoft.com/en-us/library/cc668201(v=vs.100).aspx



来源:https://stackoverflow.com/questions/16055444/asp-net-mvc-how-to-suppress-showing-default-culture-in-url

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