我定义了一个自定义路线:
routes.MapRoute(
"FabricDetails", // Route name
"fabric/details/{designerUrlFriendlyName}/{collectionUrlFriendlyName}/{fabricUrlFriendlyName}", // URL with parameters
new { controller = "Fabric", action = "Details", designerUrlFriendlyName = UrlParameter.Optional, collectionUrlFriendlyName = UrlParameter.Optional, fabricUrlFriendlyName = UrlParameter.Optional }, // Parameter defaults
new[] { "StashFabrics.Web.Controllers" }
);
我有两个几乎相同的动作链接,一个正在工作,另一个没有
@Html.ActionLink(fabric.FabricName, "Details", "Fabric", new RouteValueDictionary(new { designerUrlFriendlyName = fabric.DesignerUrlFriendlyName, collectionUrlFriendlyName = fabric.CollectionUrlFriendlyName, fabricUrlFriendlyName = fabric.FabricUrlFriendlyName }), null)
@Html.ActionLink(fabric.FabricName, "Details", "Fabric", new RouteValueDictionary(new { designerUrlFriendlyName = fabric.DesignerUrlFriendlyName, collectionUrlFriendlyName = "grand_hotel", fabricUrlFriendlyName = fabric.FabricUrlFriendlyName }), null)
无论出于何种原因,一旦我替换了 collectionUrlFriendlyName 的硬编码值,链接就无法正确构建
http://localhost:55089/Fabric/Details?designerUrlFriendlyName=jenean_morrison&collectionUrlFriendlyName=grand_hotel&fabricUrlFriendlyName=ballroom_in_azure
http://localhost:55089/fabric/details/jenean_morrison/grand_hotel/ballroom_in_azure
这让我很难过。任何意见,将不胜感激。