I have an MVC 2.0 application where I have a list of items that can be browsed by their first letter and I have a tab on the master page for the whole list of items.
What I would like is that the tab on the master page always should go to:
/items
And there are the letters of the abc that go to the items starting with the letter. So for example for the a it should go to:
/items/a
To generate the link for the tab in the master page I use:
Url.Action("Index", "Items")
The problem is that if I am looking at the items starting with a, so I am at /items/a then the tab also points to this location and not just /items. 
Anyone knows why is that, and what can I do to always point to /items in the tab using proper UrlHelper methods?
EDIT: and my routs are the following:
    routes.MapRouteLowercase(
        "DefaultPrefixed",                                              // Route name
        "{controller}/{action}/{q}",                           // URL with parameters
        new { controller = "Items", action = "Index", q = "" },  // Parameter defaults
        new { q = @"[a-z]{1}" }                                        // constraint
    );
    routes.MapRouteLowercase(
        "Default",                                              // Route name
        "{controller}/{action}/{id}",                           // URL with parameters
        new { controller = "Home", action = "Index", id = "" }  // Parameter defaults
    );
This will depend on your routes but assuming you are using the default route:
routes.MapRoute(
    "Default",
    "{controller}/{action}/{id}",
    new { controller = "Users", action = "Index", id = UrlParameter.Optional }
);
You can always optional route values to blank:
Url.Action("Index", "Items", new { id = string.Empty })
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With