I’m having what I think is a routing issue. Here’s my route:
context.MapRoute
(
"MonthYearRoute", // Route name
"TimeEntry/{action}/{month}/{year}", // URL
new { controller = "TimeEntry", action = "Month" }, new { month = new IntConstraint(), year = new IntConstraint() } // Defaults
);
Here’s my ActionLink code:
@Html.ActionLink(
"By Week",
"Month",
"TimeEntry",
new { month = Model.MonthNumber, year = Model.YearNumber },
new { @class = GetClassName("TimeEntry", "Month") }
)
This is supposed to create a url like this:
“/TimeEntry/Month/12/2011”
But it’s producing this:
“TimeEntry/Month?month=12&year=2011”
How do I format the URL to look like “/TimeEntry/Month/12/2011”?
Thanks for your time.
It’s probably due to the order of route definitions in your Global.asax. Make sure that your specific routes are before generic routes.