0

我需要这样的路线:
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.
如何通过路由配置实现这一点?谢谢你。

4

1 回答 1

0

需要使用一个静态关键字找到指定的url

于 2012-09-05T11:12:49.520 回答