Yesterday I was implementing a new SiteMap menu and had to apply a boat load of business rules to the menu. At first I thought I could hide certain menu items by using Roles. However I quickly realized that not only do I have to apply these business rules based on roles but certain configuration settings as well, so roles would not work. Since the SiteMap file is essentially a static XML file I really didn't want to do any XML parsing. I felt it would be far too expensive to edit the XML in memory. So finally this morning I found what I needed. A simple way to remove items from a sitemap.
protected void MasterMenu_MenuItemDataBound( object sender, MenuEventArgs e ) {
if( e.Item.Text == "Account" ) {
MasterMenu.Items.Remove( e.Item );
}
}
The only issue I have with this method is that I have to run through my business logic for every item in the menu.