SiteMap Question

Jun 8, 2010 at 4:03 PM
I want to use a different sitemap file for the main part of my site. I looked at some configurations on how to do this but I could not get it to work. The one for the Admin part works great and I still want to use it, I just want to add one for the main part of the site. Here is what I have in the web config file. If you could please look at it and tell me what I need to make this work. I will show you the part i added. I have it commented out. <!-- IMPORTANT!************************************************************* --> <!-- Sitemap provider for admin section navigation --> <!-- Help below Please ***************************************************** --> <!--I added the second line of code below MainSiteProvider so I can use a sitemap for the main part of the site, well it does not work. Can you fix this for me please? --> <siteMap defaultProvider="AdminSiteMapProvider" enabled="true"> <providers> <add name="AdminSiteMapProvider" description="Admin SiteMap Provider" type="System.Web.XmlSiteMapProvider" siteMapFile="~/Admin/Web.sitemap" securityTrimmingEnabled="true"/> <add name="MainSiteMapProvider" description="Main SiteMap Provider" type="System.Web.XmlSiteMapProvider" siteMapFile="Web.sitemap" securityTrimmingEnabled="true"/> </providers> </siteMap> Thanks in advance rcla396
Jun 9, 2010 at 9:14 PM


In web.config:

1.) Add a new line under the admin sitemap provider entry in site root web.config like this:
<add name="MainSiteMapProvider" description="Main SiteMap Provider" type="System.Web.XmlSiteMapProvider" siteMapFile="~/Web.sitemap" securityTrimmingEnabled="true"/>

2.) According to the above variables, add a sitemap to the root of the site. Inside this file add the following:

<?xml version="1.0" encoding="utf-8" ?> // this line is already there in a new empty file so you can skip it.
<siteMap xmlns="" >
    <siteMapNode url="#" title="none"  description="none">
        <siteMapNode url="~/default.aspx" title="Home"  description="Welcome to my site" />
        <siteMapNode url="~/login.aspx" title="Login"  description="Enter user name and password to login" />
        <siteMapNode url="~/register.aspx" title="Register"  description="Create an account" />
        <siteMapNode url="~/recover-password.aspx" title="Lost Credentials"  description="Recover your lost password" />

3.) In your page or master page where you want the menu, add the following:

<asp:Menu ID="Menu2" runat="server" Orientation="Horizontal" CssSelectorClass="YourCSSClassNameFromYourCSSFile" DataSourceID="FrontSiteMapDS">
<asp:SiteMapDataSource ID="FrontSiteMapDS" runat="server" SiteMapProvider="MainSiteMapProvider" ShowStartingNode="false" />

You can play around with this, change the properties and see what happends when you do. However, I would recommend to use a nice jquery menu on the front end for cleaner output. There are so many scripts you can find online and just modify them to suite your needs.