我需要做什么才能将这些 URL 映射到我的路线?
example.com/checkout?o=1234
example.com/checkout/shipping?o=1234
example.com/checkout/payment?o=1234
example.com/checkout/review?o=1234
example.com/checkout/receipt?o=1234
在 RouteConfig 中,我定义了这些:
routes.MapRoute(
name: "Checkout",
url: "checkout",
defaults: new { controller = "Checkout", action = "Index", o = UrlParameter.Optional }
);
routes.MapRoute(
name: "checkout Prefix",
url: "Checkout/{controller}/{action}/{o}",
defaults: new { controller = "Shipping|Payment|Review|Receipt", action = "Index", o = UrlParameter.Optional }
);
控制器文件夹是:
Controllers
CheckoutController.cs
Checkout
ShippingController.cs
PaymentController.cs
ReviewController.cs
ReceiptController.cs
当我切换订单但首先是结帐前缀时,它会弄乱“结帐?o =”路线。当我将 Checkout 路线放在第一位时,第二条路线永远不会被击中。