我需要路线如下:
http://localhost/{productName}/{featureName}
其中productName = productId + URL friendly product name
,例如1-some-product-name和featureName = featureId + URL friendly feature name
,例如1 - 一些特征名称
为了实现这一点,我写了以下路线:
routes.MapRoute(
name: "ConcreteFeatureRoute",
url: "{productName}/{featureName}",
defaults: new { controller = "Feature", action = "FeatureDetails" },
constraints: new { productName = @"\d+?-[^/]*", featureName = @"\d+?-[^/]*" }
);
但结果我得System.InvalidOperationException: No route in the route table matches the supplied values.
我如何通过路由配置实现这一目标?
谢谢。
答案 0 :(得分:0)
需要使用一个静态关键字来查找指定的网址