I'm using the MVC beta to write a simple application to understand ASP.Net MVC. The application is a simple photo/video sharing site with tagging. I'm working off the MVC skeleton project. I added some Html.ActionLink()'s to the navigation bar, but I'm having a problem with one of the Html.ActionLink()'s that I added in one spot.
I want ~/Tags to show all tags from the database and I want ~/Tags/{tag} to show a listing of all the files that are tagged with {tag}. This works as expected, but when I follow a ~/Tags/{tag}, it changes the Html.ActionLink() in the navigation bar to be the same as the ~/Tags/{tag} link instead of just pointing to ~/Tags. I'm not understanding why the ActionLink() in my navigation bar is changing when I follow the ~/Tags/{tag}. If I navigate to a different link in the project, the ActionLink() works as expected.
I have the actionlink and route set up like this. My TagsController has this Index action. The int? is for a paging control. I have two Views, one called All and one called Details. What am I doing wrong?
Html.ActionLink("Tags", "Index", "Tags") // In navigation bar
routes.MapRoute(
"Tags",
"Tags/{tag}",
new
{
controller = "Tags", action = "Index", tag = "",
});
public ActionResult Index(string tag, int? id )
{ // short pseudocode
If (tag == "")
return View("All", model)
else
return View("Details", model)
}