When business requirements infest a projects progress desperation turns into frustration which in turn ends up as lost hope. I’ve spent the last week spending my personal time researching what ways I can approach navigation using some SiteMap implementation in MVC for ASP.NET. Unfortunately I never did find a decent solution, but in the midst of it all I’ve had to come up with an alternative solution which, whilst not as elegant, meets the “business requirements”.
The requirements were actually to have a Windows-style navigation, one without the navigation tree but instead a folder-like structure. I can’t deviate from this, regardless of how inefficient it is from a user-perspective simply because the users are so tied into this navigation model that any other approach would lead to frustration and complaints from the end-user. When developing applications you don’t meet the developers needs, you work to the user, which in many-an-environment, is a unique individual with unique requirements. Whilst we can abstract the user process and make recommendations we must also ensure a happy-to-use environment based on familiarity (that being the folder-like structure of navigation).
So why won’t MvcSiteMap work? Well, I’m using Areas Lib, and MvcSiteMap doesn’t work with Areas Lib, so this is a complete no-go. MvcSiteMap is simply an MVC implementation of Microsoft’s original SiteMap control for ASP.NET. The library is highly rated by many developers, and seems very good. Areas Lib is something I have to use, it’s absolutely fundamental to the workings of the application, so I’m very thankful for that.
So, what I’ve come up with in the mean time? Well I’m using partial views and wrote a HTML helper to figure out what menu it should render. The good thing about it is that currently no logic is required, it just picks up the file and reads it into memory without having to worry about the content whatsoever. It does mean that a basic folder structure is needed to place the menu.ascx files about the place. It also still conforms to the general MVC architecture as it’s simply picking a view based on the controller action. Unfortunately I can’t give you the code, but it’s not hard to write a HTML helper to pick up a *.ascx file and read it into memory. The next step is achieving a security model in the partial view without breaking the MVC structure, but at least I got it to work, and that’s the important thing in this case.
This does show though that Microsoft’s MVC implementation for ASP.NET isn’t quite up to par with competing architectures such as Ruby on Rails.