Bookmark and Share

Friday, February 01, 2008

ASP.NET 2.0 Sitemap

Here is a working example of sitemap in asp.net 2.0, remember that the control works in conjunction with web.config location security settings

<?xml version="1.0" encoding="utf-8" ?>
<
siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0">
<
siteMapNode url="~\default.aspx" title="Home" description="" roles="*">
<
siteMapNode title="Folder1" description="" url="" roles="*">
<
siteMapNode url="~\Page1.aspx" title="Dati Agenzia" description="" roles="Admin" />
<
siteMapNode url="~\Page2.aspx" title="Dati Personale" description="" roles="NormalUser"/>
</siteMap>


And here's the settings in web.config:

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

Is also important to set the permission on the web.config file, like this:

<location path="ADMIN">
<
system.web>
<authorization>
<
deny roles="NormalUser" />
</authorization>
</
system.web>
</
location>

No comments:

Post a Comment