Reputation: 4702
I just updated my Asp.Net Mvc 2 project to Mvc 3 and suddenly my links stopped working. When I open a page, all links on the page redirect back to itself.
Also, some redirects to actions that used to work in the previous version don't working anymore. It keeps saying 'No route in the route table matches the supplied values.'. I used RouteDebug to see what was going on, but couldn't find any problems.
Update
Here's one of the routes i'm using:
// ** Standard route. **
context.MapRoute(
"group_default", // Route name
"{language}/{organisation}/Research.aspx/{controller}/{action}/{organisationId}/{parameter}/",
// URL with parameters
new
{
area = "research",
language = "en-US",
organisation = "",
controller = "Home",
action = "Index",
organisationId = UrlParameter.Optional,
parameter = UrlParameter.Optional
}, // Parameter defaults
new[] { "Project.Web.Areas.Research.Controllers" }
);
As you can see in my answer below, the problem was caused by two UrlParameter.Optional after each other. This is a bug in Mvc 3
Upvotes: 1
Views: 553
Reputation: 4702
Wow, after about 4 hours of debugging I found the problem: It's a bug in Mvc 3. Because of the bug, it's not possible to use two UrlParameter.Optional after each other. Phil Haack has a nice blog-post about it: http://haacked.com/archive/2011/02/20/routing-regression-with-two-consecutive-optional-url-parameters.aspx
Hope this will help others (and save them some time)
Upvotes: 2