Share via


How to hide your sitemap links?

In ASP.net 2.0, creating a sitemap using the sitemap file is really a useful to allow your web users to navigate the web pages. By default, all the sitemap links are visible to the users. So, how to hide certain links from unauthorized users?
For example, you have a sitemap here with few links, and you want to hide the "Manage Account" and "Display Reports" from some unauthorized users.
example 1
ASP.NET role management provides a way to restrict access to Web files based on security roles. Site-map security trimming provides a way to hide navigational links in a site map, also based on security roles.
First you need to create access rules for your web site on which pages unauthorized users cannot access.
You can use the Web Site Administrator Tool to assist you to create the access rules.
example 2
You create a folder to store the web pages that you want to secure it, then apply the access rules to the particualar folder. You can select which role the rule apply to, permission for the particular role. [either allow or deny]
After you have created the access rules, you can enable security trimming for your sitemap at web.config file.

<siteMap defaultProvider="default">
<providers>
<add name="default" type="System.Web.XmlSitemapProvider" siteMapFile="Web.sitemap" securityTrimmingEnabled="true"/>
</providers>
</siteMap>

Now, only authorized users can access the web pages that you have set the access rules, which based on their roles.
example 3
Go to this link to find out more on how to apply this security trimming on sitema.