我已经为我的ASP.Net MVC 2网站的以下网址:ASP.Net MVC路线混乱
http://localhost:1919/TimeEntry/SummaryForWeek/15/2011
http://localhost:1919/TimeEntry/SummaryForMonth/4/2011
这两项均创下该航线:
routes.MapRoute
(
"TimeEntryActionMonthYear", // Route name
"TimeEntry/{action}/{month}/{year}", // URL with parameters
new { controller = "TimeEntry", action = "Summary", month = UrlParameter.Optional, year = UrlParameter.Optional } // Parameter defaults
);
为SummaryForWeek的动作期望一个名为“weekNumber”的参数(上面的URL中的15值),而正在使用的路由传递一个名为“month”的参数,因此weekSummary的URL失败。将SummaryForWeek的参数从一周改为月份是没有意义的,只是路由才起作用。
我应该为“SummaryForWeeks”硬编码添加一个路由路由表,其中{action}是硬编码的吗?由于它膨胀了路线表,这没有意义。
我不理解什么(我知道这让我想起了一些创造性的评论)?我卡住了。
感谢
汤姆
绑定问题:http://stackoverflow.com/questions/2743223/asp-net-mvc-routing-id-parameter/4304147#4304147 – 2011-04-14 21:22:29