timbck2
timbck2

Reputation: 1066

ASP.NET Web.Sitemap - one role not being displayed in nav menu while others are

I'm working on an ASP.NET C# application that has three roles defined for various user levels within the application: "User", "Manager", and "Admin". I've completed most of the User and Admin stuff, and just added a page to the Manager section. But the "Manager" section isn't showing up in my TreeView navigation menu. I read the excellent blog article at http://blogs.ipona.com/davids/archive/2009/01/12/8554.aspx, and I appear to be following all the "rules" he defines, but it still isn't working.

Here's my Web.sitemap file:

<?xml version="1.0" encoding="utf-8" ?>
<siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0">
  <siteMapNode url="#">
    <siteMapNode url="~/User/Default.aspx" roles="Admin,Manager,User" title="Home" />
    <siteMapNode url="~/User/About.aspx" roles="Admin,Manager,User" title="About" description="About this application" />
    <siteMapNode roles="Admin,Manager,User" title="User Functions">
      <siteMapNode url="~/User/CreateNewIPR.aspx" roles="Admin,Manager,User" title="Create New IPR" description="Enter a new IPR" />
      <siteMapNode url="~/User/ListIPRs.aspx" roles="Admin,Manager,User" title="List IPRs" description="List all the IPRs you have entered" />
      <siteMapNode url="~/User/ViewIPRDetails.aspx" roles="Admin,Manager,User" title="View IPR Details" description="View details of an IPR" />
    </siteMapNode>
    <siteMapNode roles="Admin" title="Admin Functions">
      <siteMapNode url="~/Admin/ManageApprovalLevels.aspx" roles="Admin" title="Manage Approval Levels"
               description="Allows administrators to add/edit approval levels" />
      <siteMapNode url="~/Admin/ManageUsers.aspx" roles="Admin" title="Manage Users &amp; Roles" description="Allows administrators to add users to roles and add new users to the system" />
      <siteMapNode url="~/Admin/ManageApprovers.aspx" roles="Admin" title="Manage Approvers" description="Allows administrators to manage approvers" />
    </siteMapNode>
    <siteMapNode roles="Manager" title="Manager Functions">
      <siteMapNode url="~/Manager/ApprovalsList.aspx" roles="Manager" title="Approve Purchase Requests" description="Allows managers to approve purchase requests" />
    </siteMapNode>
  </siteMapNode>
</siteMap>

Here's the Web.config from the "Manager" folder:

<?xml version="1.0"?>
<configuration>
  <system.web>
    <authorization>
      <allow roles="Admin,Manager" />
      <deny users="*" />
    </authorization>
  </system.web>
</configuration>

And finally, here's where I define the SiteMap provider in the root Web.config:

<siteMap defaultProvider="XmlSiteMapProvider" enabled="true">
  <providers>
    <add name="XmlSiteMapProvider" description="Default SiteMap provider" type="System.Web.XmlSiteMapProvider" siteMapFile="IPRTracker.sitemap" securityTrimmingEnabled="true" />
  </providers>
</siteMap>

Here's a screen capture of what I get (note that the Manager section is missing):

Screen capture showing NavMenu

Upvotes: 0

Views: 1500

Answers (1)

timbck2
timbck2

Reputation: 1066

Well, it turned out to be something fairly simple, though I don't completely understand it. In the Web.sitemap, the following line:

<siteMapNode roles="Manager" title="Manager Functions">

needed to be changed to:

<siteMapNode roles="Admin,Manager" title="Manager Functions">

even though the userid I'm testing with is a member of all three roles (Admin, Manager, and User).

Upvotes: 0

Related Questions