答案 0 :(得分:0)
您可以使用某种“语言”注册路径作为路径的第一部分,并处理诸如行动参数之类的信息。
routes.MapRoute(
name: "Category",
url: "{language}/Category",
defaults: new { controller = "Category", action = "Index" },
);
ActionResult Index(string language,...)
{
// set language based on Url
// i.e. if you are using "en-GB" as language (.Net culture names)
Thread.CurrentThread.CurrentCulture = new CultureInfo(language);
Thread.CurrentThread.CurrentUICulture = new CultureInfo(language);
}
请注意,有许多方法可以重构此类代码以避免重复(即编写ActionFilter来执行此操作)。