请有人对这个问题有所了解,这让我发疯!
路线:
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
"DefaultOrderingRoute", // Route name
"{controller}/{action}/{id}/{slug}", // URL with parameters
new { controller = "Order", slug = UrlParameter.Optional }, // Parameter defaults
new { controller = "^Order$" }
);
routes.MapRoute(
"DefaultImageRoute", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Image", }, // Parameter defaults
new { controller = "^Image$" }
);
routes.MapRoute(
"FooterRoute", //route for invoking actions for the Footer
"{controller}/{action}", // URL with parameters
new { controller = "Footer", }, // Parameter defaults
new { controller = "^Footer$" }
);
routes.MapRoute(
"DefaultDealRoute", // Route name
"{city}/{category}/{id}/{slug}", // URL with parameters
new { category = Deals.Globals.Global.CATEGORY_ALL_NAME, controller = "Deal", action = "Details", slug = UrlParameter.Optional }, // Parameter defaults
new { controller = "^Deal$", id = @"\d+" }
);
routes.MapRoute(
"DealRouteForCategory", // Route name
"{city}/{category}", // URL with parameters
new { city = "", category = Deals.Globals.Global.CATEGORY_ALL_NAME, controller = "Deal", action = "Details" }, // Parameter defaults
new { controller = "^Deal$" }
);
}
我添加了对 routedebugger 的引用,以查看引擎盖下发生了什么。因此,对于选定的 URL:
http://my.SERVER.IP/VirtualDirectoryName/Order/PayPalNotify/9/blabla
URL 调试器显示以下内容:
AppRelativeCurrentExecutionFilePath: ~/Order/PayPalNotify/9/adfaf (正是我所期望的)!!!
调试器还显示路由 DefaultOrderingRoute 和 DefaultDealRoute 匹配(这是我没想到的!因为我对路由有限制!!)。
它还表明匹配的路由是:
匹配路线:{controller}/{action}/{id}/{slug}
带有路线数据:
controller: Deal
action: Details
id: 9
slug: adfaf
city: Athens
category: All
这怎么可能??我究竟做错了什么?
PS。我注意到通过重新发布URL 正确的路由被执行!!!