ASP.NET MVC routes
-
07-07-2019 - |
Question
I need help with this route map
routes.MapRoute("Blog_Archive",
"Blog/Archive/{year}/{month}/{day}",
new {
controller = "Blog",
action = "archive",
year = "",
month = "",
day = "",
page = 0
});
When I call http://localhost:5060/blog/Archive/2008/11, it picks up the year and month and sends it to the controller. But when I try http://localhost:5060/blog/Archive/2008
it sends it to the controller but the year parameter is null and so are all the other parameters.
Solution
Do you have any other Route for Blog/Archive/{something}?
Use the Routing Debugger to see which route actually gets hit, most likely it's not hitting that route.
OTHER TIPS
Subnus, I noticed in your code that you have routes.IgnoreRoute("favicon.ico"); I don't think this is required with MVC 1.0 right because the period is no longer ignored correct?
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow