views:

54

answers:

2

Hi all,

I'm stuck with a problem of which I can not imagine I am the first person having to deal with it. Yet, Google comes up with nothing useful and neither does SO, so here I am.

I'm using ASP.NET MVC1 with a sitemap. Using an html helper I create a navigation menu that highlights the current selected option in the Site.Master page. Common scenario and easily done by using :


foreach ( SiteMapNode subnode in node.ChildNodes) {
    if (SiteMap.CurrentNode == subnode) { //got ourselves the current here }
}

That's all fine and dandy, however, my problem is that I have 1 controller with multiple actions. Consider the following scenario:

Accounts * clients * suppliers * maintainance

They would all be in my AccountController, doing a search that is identical but with a different AccountTypeId value.

When I read the SiteMap.CurrentNode value it gives me merely the info that I am using the AccountController, but not which action I called. I've tried a whole bunch of things but I can not get the action that was requested.

I hope I gave enough info there to give you an idea of the scenario. If you need anything else, let me know.

Thanks in advance :)!

PS: Tossed into asp.net since about 2 months here at work so bear with me. Programming experience is here but C# / .NET knowledge is mostly equal to what Google or co-workers can provide me with.

EDIT: -- In response to bob's answer below --

I have came across the SiteMap Provider project however I didn't gave it much attention since I'm using MVC1 and it's aimed at MVC2. Additionally, I'm not quite sure if we are already using it or not...After all, I have a sitemap... And the person who could tell me at the office is chillin' on a beach somewhere for the next 2 weeks :(

A: 

Have you looked at RouteData.Values["action"]. It's kind of tricky to work out if this might help.

Simon Hazelton
I have but it doesn't seem to hold much data for me. It seems like the data about the action is already stripped away at the time of calling it... or maybe not added yet in the first place.
Reinier
A: 

you could try this ASP.NET MVC SiteMap provider first result when you search mvcsitemap in google

rob waminal
Considering it *is* the first hit in Google, I have looked at it. The front page however starts with the mention "Targeted at ASP.NET MVC 2". Considering the fact I use MVC v1 and my inexperience with ASP as well asfact that, as far as I can tell, MVC2 is quite a large leap from MVC1 I didn't look into it much further.Though I might have to add that to the main post actually since it's so obviously related... :)
Reinier
there's no very big difference between MVC1 and MVC2, just some added features. most features in MVC1 are still used in MVC2. I'm pretty sure that this will work in MVC1 since this is just an extension. I've partially read the instructions and it's most likely to work in MVC1.. anyway there's no harm in trying :)
rob waminal
Rob, thought I'd get a notification about comments so missed this one. When the boss lets me, I'll check it out ;)! Thank you for taking the time to check up on it.
Reinier
@Reinier, no problem
rob waminal