Horizontal Menu Disappears with securityTrimmingEnabled="true"

I'm implementing ASP.NET roles in a site and using the securityTrimmingEnabled feature so people don't see menu items for pages they're not authorized to visit.

Once I got the roles and restrictions enabled, the entire menu disappeared as if the role had no authorization to see any items. That's security trimming gone wild!

It turns out that this is an issue when you're using a horizontal ASP.NET menu. You usually hide the root node of the sitemap file when using a horizontal menu because a top row with one lonely root item doesn't make sense. (The SiteMapDataSource ShowStartingNode property is set to False.)

The fix was to make sure that every role had access to the (unused) dummy siteMapNode at the root by including roles="*"  in web.sitemap shown below:

<?xml version="1.0" encoding="utf-8" ?>
<siteMap  enableLocalization="true"
     xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" >
    <siteMapNode url="" title="" roles="*"  description="">
      <siteMapNode url="~/default.aspx" resourceKey="siteMapHome" 
       title="Home" roles="admin,account" description="" />
<!-----More nodes-->

Sheesh! Why do I lose time on these silly things? Is nothing ever easy?

 

Published 12 February 2008 03:00 PM by Ken Cox [MVP]
Filed under: , , ,

Comments

# Horizontal Menu Disappears with securityTrimmingEnabled="true" - WebLog of Ken Cox said on 12 February, 2008 06:23 PM

Pingback from  Horizontal Menu Disappears with securityTrimmingEnabled=&quot;true&quot; - WebLog of Ken Cox

# Horizontal Menu Disappears with securityTrimmingEnabled=”true” | videositemap.com said on 12 February, 2008 08:24 PM

Pingback from  Horizontal Menu Disappears with securityTrimmingEnabled=&#8221;true&#8221; | videositemap.com

# rajbk said on 12 February, 2008 08:44 PM

More info here:

blogs.msdn.com/.../553005.aspx

# drag said on 28 March, 2008 06:41 AM

you are a genius my friend!!!!

thanks for sharing your experience!

i spent hours trying to solve exactly the same  problems!

keep up the good work!

ta

# SP said on 30 March, 2008 09:33 AM

Thanks dude.

# prisLena said on 06 May, 2008 05:44 PM

What a magic.  You made my day and saved me from frustrations.  Thank you

# WotlkPowerLeveling.com said on 04 November, 2008 03:33 AM

Yes, its works for me too, thanks

# kj said on 13 November, 2008 11:03 AM

Thanks!  I had been trying to figure this one out all morning.

# a friend said on 16 December, 2008 09:01 PM

I was reading MSDN and the correct form to resolve this issue is to write roles="*"

# Salomon said on 25 February, 2009 09:32 AM

Thanks ALOT ! Thanks for sharing !!!

# Som Nath Shukla said on 01 April, 2009 01:27 AM

thanks alot for sharing.

Leave a Comment

(required) 
(required) 
(optional)
(required) 

Search

Go

This Blog

Web Links

Syndication