我需要这样的路线:
http://localhost/{productName}/{featureName}
where productName = productId + URL friendly product name
,例如 1-some-product-name 和featureName = featureId + URL friendly feature name
,例如 1-some-feature-name
为了实现这一点,我编写了以下路线:
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.
如何通过路由配置实现这一点?谢谢你。