gpt4 book ai didi

asp.net-mvc - ASP.NET MVC。如何禁止在 URL 中显示默认文化?

转载 作者:行者123 更新时间:2023-12-04 03:09:58 24 4
gpt4 key购买 nike

这里是问题。我有一个本地化的 asp.net mvc 网站。通过后续步骤完成本地化:1. 对于每条路线,我自动添加一个默认值为“ru”的 {culture} url 段。

我希望我的网址仅包含外国文化。例如:

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

我无法到达这个,因为@Url.Action 方法总是返回带有文化的 url,即使它是默认文化。请帮助我!

最佳答案

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

作为基础,您可以在这里找到解决方案
http://www.asp.net/mvc/tutorials/older-versions/controllers-and-routing/asp-net-mvc-routing-overview-cs在 msdn 上
http://msdn.microsoft.com/en-us/library/cc668201(v=vs.100).aspx

关于asp.net-mvc - ASP.NET MVC。如何禁止在 URL 中显示默认文化?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16055444/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com