In ASP.NET MVC, I am building a site with the requirement that the main menu (appearing on every page) should remove the hyperlink for an entry (leaving just the text) if the current page is the one linked to.
The menu html is defined in the master page for the site, but is currently populated from the ViewData passed by the controller. This is set up so that the base controller defines a dictionary of link objects, then the actions on the controllers grab the relevant entry out of the dictionary, set the address to empty. The base controller then passes it to the view as an IEnumerable<>
.
However, looking at it with a critical eye, it feels more like something the view should have sole responsibility for: the menu doesn't change, so the controller feels like it's butting in where it shouldn't. My only slight reservation is that the View would be knowledgable about what the current page is, which feels like more of a controller concern.
I've been arguing around in circles in my head for a while now, so I'd like some other opinions on this. I would have thought this would be a fairly common scenario?
(One final clarification to my problem: the main menu links are to "landing pages" of the various areas of the site (basically the Index action of all the controllers), and once you've navigated into the area and are off the landing page, all entries in the menu will be linked)