我正在一个交易网站上工作,并在 global.asax 中定义了以下路线。
routes.MapRoute(
"AboutFooter",
"about-bicker-shop",
new { controller = "Footer", action = "About" }
);
routes.MapRoute(
"ContactFooter",
"contact-bickershop",
new { controller = "Footer", action = "Contact" }
);
routes.MapRoute(
"PrivacyPolicyFooter",
"privacy-policy",
new { controller = "Footer", action = "PrivacyPolicy" }
);
routes.MapRoute(
"TermsAndConditionsFooter",
"terms-and-conditions",
new { controller = "Footer", action = "TermsAndConditions" }
);
routes.MapRoute(
"SiteMapFooter",
"sitemap",
new { controller = "Footer", action = "SiteMap" }
);
routes.MapRoute(
"FAQFooter",
"faq",
new { controller = "Footer", action = "FAQ" }
);
routes.MapRoute(
"UnsubscribeFooter",
"unsubscribe",
new { controller = "Footer", action = "Unsubscribe" }
);
routes.MapRoute(
"GetDealsByCity",
"daily-bickers/{cityName}",
new { controller = "Home", action = "Home" }
);
routes.MapRoute(
"GetDealsbyCategory",
"daily-bickers/{cityname}/{category}",
new { controller = "Home", action = "GetDealsByCategory" }
);
routes.MapRoute(
"GetDealDetails",
"{cityName}/{dealName}",
new { controller = "Home", action = "GetDealsByDealName" }
);
routes.MapRoute(
"DealCheckout",
"{cityName}/{dealName}/checkout",
new { controller = "Home", action = "CheckoutDealByDealName" }
);
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
);
在我查看交易详情之前它工作正常,但是当我点击购买按钮购买交易时出现错误。
在进一步的研究中,我发现点击购买按钮时,代码调用的是GetDealsByDealName
action 而不是 action CheckoutDealByDealName
。请建议我解决方案。