MVC Preview 4 - No route in the route table matches the supplied values *

Question

I have a route that I am calling through a RedirectToRoute like this:

return this.RedirectToRoute("Super-SuperRoute", new { year = selectedYear });

I have also tried:

 return this.RedirectToRoute("Super-SuperRoute", new { controller = "Super", action = "SuperRoute", id = "RouteTopic", year = selectedYear });

The route in the global.asax is like this:

routes.MapRoute(
            "Super-SuperRoute", // Route name
            "Super.mvc/SuperRoute/{year}",  // URL with parameters
            new { controller = "Super", action = "SuperRoute", id = "RouteTopic" }  // Parameter defaults
        );

So why do I get the error: "No route in the route table matches the supplied values."?

I saw that the type of selectedYear was var. When I tried to convert to int with int.Parse I realised that selectedYear was actually null, which would explain the problems. I guess next time I'll pay more attention to the values of the variables at a breakpoint :)

Answer

What type is selectedYear? A DateTime? If so then you might need to convert to a string.

< br > via < a class="StackLink" href=" http://stackoverflow.com/questions/5690/" >MVC Preview 4 - No route in the route table matches the supplied values< /a>
Share on Google Plus

About Cinema Guy

This is a short description in the author block about the author. You edit it by entering text in the "Biographical Info" field in the user admin panel.
    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment