我正在處理交易網站,並在global.asax中定義了以下路由。ASP.Net MVC3路由問題
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
操作,而不是操作CheckoutDealByDealName
。請給我解決方案。
需要查看生成鏈接的方式,以瞭解爲什麼它們可能無法正確路由。 – mckeejm
您可以將標記貼上您正在使用的操作鏈接或按鈕嗎? – AntLaC
–