views:

736

answers:

1

Hi,

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."?

Thanks to Ricky for putting me on the right track. 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 :)

+3  A: 

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

Ricky