views:

540

answers:

1

There seem to be a lot of issues on SO dealing with MapRoute problems. I've read through a bunch of them, but I can't see what I'm doing wrong in my implementation. I've got the following routes set up:

routes.MapRoute( _
    "FilesDisplay", _
    "{controller}/{action}/{year}/{month}", _
    New With {.controller = "Files", .action = "Display", .year = "", .month = ""})

routes.MapRoute( _
    "Default", _
    "{controller}/{action}", _
    New With {.controller = "Files", .action = "Index"})

and the following RouteLink:

<%=Html.RouteLink("Show", "FilesDisplay", New With {.year = 2008, .month = 5})%>

However, the resulting URL for "Show" is /Files/Index/2008/5. Why is it picking up the Index action instead of the Display action?

Edit: As a lark I changed the second route to .action = "Display" just to see if I could get the URL to change, and it still resolves to /Files/Index/2008/5.

Edit 2: I also tried:

<%=Html.ActionLink("Show", "Display", "Files", New With {.year = 2008, .month = 5}, Nothing)%>

but that also resolves to /Files/Index/2008/5. Why is it that no matter what I specify for an action it's defaulting to Index?

A: 

Upgrading to MVC RC 1.0 seemed to fix ActionLink but not RouteLink. Therefore I'm moving forward with ActionLink. I'd love to know why RouteLink doesn't want to work though.

gfrizzle