0
我试图定义一个路由配置,这将使一个可选的“区域”在下面的网址,所有这些都将默认主页:如何解决这个路由配置?配置的路由返回404
/uk/home // where the 'uk' parameter can be either 'uk' or 'us'
/uk // where the 'uk' parameter can be either 'uk' or 'us'
/ // in this case, I just want the region to default to 'uk'
结果我虽然变得不理想。第一个(/uk/home
),而第三个(/
)都工作,但第二个(/uk
),返回404
的配置被定义为:
routes.MapRoute(
null,
"{region}/{controller}",
new { region = "^UK|US$" },
new { controller = "Home", action = "Index" }
);
routes.MapRoute(
null,
"{region}",
new { region = "^UK|US$" },
new { controller = "Home", action = "Index" }
);
routes.MapRoute(
null,
//"{region}",
"",
new {region = "UK", controller = "Home", action = "Index" }
);
我需要做什么来确保所有3个URL都默认为主页,空URL将默认地区设为'英国'?