【发布时间】:2012-10-25 19:15:06
【问题描述】:
我在一个交易网站上工作,并在 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 操作,而不是CheckoutDealByDealName 操作。请给我建议解决方案。
【问题讨论】:
-
需要查看链接的生成方式以了解它们可能无法正确路由的原因。
-
您可以张贴您正在使用的操作链接或按钮的标记吗?
-
生成以下链接 - http://{url}/{controller}/{action}?cityname="{cityname}anddealname="{dealname}/checkout 而我的期望是 http: //{url}/{cityname}/{dealname}/checkout
标签: asp.net-mvc asp.net-mvc-3 asp.net-mvc-routing