【发布时间】:2020-03-06 23:25:53
【问题描述】:
我正在尝试两种不同的方法来在我的多语言网站中设置路线。
使用 RouteConfig.cs,以下两种语言都可以正常工作:
route = routes.MapRoute(
name: "DataVesselRegister",
url: "{culture}/Data/staff",
defaults: new { action = "Index", controller = "Staff", culture = defaultCulture.Name },
constraints: new { culture = new SiteCultureConstraint(AppConfig.Sitename) }
);
// A route value determines the culture of the current thread
route.RouteHandler = new MultiCultureMvcRouteHandler();
但是,当我尝试使用 Route 属性来做同样的事情时:
[Route("{culture}/data/staff")]
[HttpGet]
public ActionResult Index()
{
该网站仍以英语作为其默认语言。
为什么我不能在控制器中使用路由属性实现相同的行为。
【问题讨论】:
标签: asp.net-mvc routes