asp.netsitemapquerystringparametersitemapproviderweb.sitemap

query string parameters for sitemap


I'm using VWD 2010, ASP.NET with C#. I found a pointer for how to do this in another SO post. Unfortunately, I can't get it working.

The sample code it points to is here: http://weblogs.asp.net/jgaylord/adding-querystring-parameters-to-the-sitemapnode

I have included the C# code for this, but I can't seem to get the program to recognize that the code is actually there. I set break points that never get invoked.
I put this into the web.config:

    <siteMap enabled="true">
      <providers>
        <clear/>
        <add name="ExtendedSiteMapProvider" type="Configuration.ExtendedSiteMapProvider" siteMapFile="web.sitemap" securityTrimmingEnabled="true" />
<!--
        <add siteMapFile="Web.sitemap" name="AspNetXmlSiteMapProvider" type="System.Web.XmlSiteMapProvider" securityTrimmingEnabled="true"/>
    -->    
      </providers>
    </siteMap>

Notice how AspNetXmlSiteMapProvider is commented out. That name appears nowhere else in the file. Nevertheless when I attempt to run my program, I get this error message: The provider 'AspNetXmlSiteMapProvider' specified for the defaultProvider does not exist in the providers collection.

If I uncomment that line, the program runs, but the new code is never invoked. Any ideas?


Solution

  • That's because you are not specifying the defaultProvider which defaults exactly to AspNetXmlSiteMapProvide, like you can see here.

    So you just have to specify the defualt provider like this:

    <siteMap enabled="true" defaultProvider="ExtendedSiteMapProvider">
      <providers>
        ....
      </providers>
    </siteMap>
    

    Or specify the provider in corresponding SiteMpaDataSource property, so that the default isn't used.