现在我有一个匹配的地图路线
foreach(var subcat in Sports.Categories)
{
routes.MapRoute("MultiRoute" + i, subcat+"/{title}",
new { controller = "Routing", action = "Redirect", category = subcat });
}
我有一些运动类别:棒球、足球、篮球等,但我也想将篮球与 BasketBall-Plays、BasketBall-Highlights、Top-10-Basketball 等相匹配...
这意味着我必须允许 subcat 在之前和之后使用通配符,因为 BasketBall-Plays 包含单词 Basketball,我希望它重定向到那里。
如何为地图路由创建包含部分?
编辑:TLDR:我有一个名为篮球的子猫,但我想匹配每个包含篮球一词的网址。所以 Basketball-plays/top-10 实际上应该打篮球/top-10
试过:
foreach(var subcat in Sports.Categories)
{
routes.MapRoute("MultiRoute" + i, subcat+"/{title}",
new { controller = "Routing", action = "Redirect", category = subcat }),
new{sub = ".*"+sub+".*" });
}