Blind leading the blind

I’m about two thirds of the way through the Visual Web Developer book i got this week

I’ve just created a site map file, enabled security trimming in the web.config file but couldn’t get one of my menu entries to only appear when logged in

Normally i read it first, then create it myself instead of just blindly copying the example

I just wanted two entries. A general page for anyone and a members only page.

Home
|—Members Only
|—General

So this is node section of my web.sitemap file

 <siteMapNode url=”~/Default.aspx” title=”Home”  description=”Go to home page”>
  <siteMapNode url=”~/MemberPages/MembersOnly.aspx”
      title=”Members only”
      description=”Members only”
      roles=”SiteMembers” />
  <siteMapNode url=”~general.aspx”
      title=”General”
      description=”General Stuff” />
 </siteMapNode>
 

When i previewed in the browser all the menu items appeared, even though i’d specified a role for it.

So i went back and copied the example to the letter….still the same

This is where i’m glad for having some experience reading Microsoft help files!

What the section in the book neglets to mention is this little snippet i found on MSDN

The security-trimming feature uses URL authorization on each request to determine whether a user has access to a URL that is associated with a siteMapNode element.

So i removed the url attribute and volia! It worked as i was expecting it to

But then i thought..”now i’ve removed that i have no link to click”

and thats when the pieces fell into place (penny drop? more like a couple of grand!)

The pages didn’t actually exist. I hadn’t created them as i was just playing with the concept and the book itself didn’t tell me to create the pages for the example it used

I had already created a change password page that only members could access so changed it to point to that

 <siteMapNode url=”~/Default.aspx” title=”Home”  description=”Go to home page”>
  <siteMapNode url=”~/MemberPages/ChangePasswordaspx”
      title=”Change Password”
      description=”Change Password Here”
      roles=”SiteMembers” />
  <siteMapNode url=”~general.aspx”
      title=”General”
      description=”General Stuff” />
 </siteMapNode>

Bingo!

I went back and looked at the chapter again and it doesn’t actually tell you specifically to create the pages…so the example would never have worked

I can’t believe i was worried though…i haven’t run into anything at the moment that i don’t get. Granted this is just a getting started book but i’m pretty pleased with myself so far!

The following two tabs change content below.
Andy Parkes is Technical Director at Coventry based IT support company IBIT Solutions. Formerly, coordinator of AMITPRO and Microsoft Partner Area Lead for 2012-2013. He also isn't a fan of describing himself in the third person.

Latest posts by Andy Parkes (see all)

1 thought on “Blind leading the blind

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.