Hi, today I ran into a problem using Multiple sitemap files in combination with a custom sitemapprovider inheriting from the XmlSiteMapProvider class. Since I couldn't find a solution to this on the web, I thought i'd share my findings ;-)
When using multiple sitemap files, you can either add a sitemapnode to your .sitemap indicating a provider for this node, or you can add a sitemapnode pointing to a different .sitemap.
-
<siteMapNode provider="myProvider" /> or
-
<siteMapNode siteMapFile="morenav.sitemap" />
Problem with the first solution is that you have to explicitly point to a provider in your web.config and thus add a provider for each sitemapfile. This creates an unwanted dependency, especially (as is the case in my situation) when the additional sitemapfile is created by someone else (a different project team for example). More importantly, you just can't go around adding providers for each external sitemapfile. It works though!
Problem with the second solution is that you can't get it to work with your custom Sitemap provider. Let's say we configure the default sitemapprovider to use a custom provider, say MySitemapProvider. When using multiple sitemap files, you'll find the custom provider is used for your main sitemap, but not for your referenced sitemap.
It took me a while to figure it out, but this is what you might call a bug in Asp.Net 2.0. It took a deep dive into reflector and some major frustration to figure it out, but the .Net framework explicitly uses the standard XmlSiteMapProvider whenever you apply the siteMapFile attribute on one of your nodes. Since these methods are private and use sealed system.web classes I couldn't find a way to program around this. If anybody has thoughts on this, feel free to share!
Oh, and another thing: the provider attribute always take precendence. You would think you could define a siteMapFile on your node and a provider to make it more generic, but you can't!
Hope this saves someone the trouble.
Cheers,
rinze