1

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

Pbirkoff
  • 4,642
  • 2
  • 20
  • 18
  • 2
    Of course we need to see the routes, why not add them on the first place??? – gdoron Jan 31 '12 at 17:31
  • Taking a wild guess here: Your routes are not registered properly. The routes you set up in your `.asax` file are setup using a bunch of overloaded methods that take a lot of strings. Perhaps they changed the order of those parameters? Otherwise, your controllers are not registered (or are not in an included namespace), if you're using the default routing system. That's all I can say without seeing a couple of your controllers and your `.asax` file. – cwharris Jan 31 '12 at 17:32

1 Answers1

2

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)

Pbirkoff
  • 4,642
  • 2
  • 20
  • 18
  • This will not help anyone because you never included the routes in your question, which would have led people to tell you exactly what you took 4 hours to find out. Please, again, include your routes in the question. Also, this question has come up on Stack Overflow before: http://stackoverflow.com/questions/7085762/why-is-this-route-parameter-tacked-onto-the-querystring – George Stocker Jan 31 '12 at 22:25
  • I've included the routes in the question. Because the symptoms in the question you're referring to are different than mine, it didn't turn up in my search-results. – Pbirkoff Feb 01 '12 at 08:10