I am currently porting an application from SharePoint 2007 to 2010. As a single page can be invoked in different contexts, we rely on a code based SiteMapResolveEventHandler to dynamically populate the breadcrumb.
This all works great in SharePoint 2007, but for some reason in SharePoint 2010 it doesn't hit the 'SPXmlContentMapProvider' event handler even though this provider is available in the list of SiteMap.Providers.
If I hook up the event to a different provider, e.g. the CombinedNavSiteMapProvider then it does trigger the event handler, but this provider does not contain the nodes I am interested in.
The following code is being used (and works fine in SP2007)
In the application page's OnLoad
SiteMap.Providers["SPXmlContentMapProvider"].SiteMapResolve += new SiteMapResolveEventHandler(provider_SiteMapResolve);
which calls the following method (simplified version)
public SiteMapNode provider_SiteMapResolve(object sender, SiteMapResolveEventArgs e)
{
e.Provider.EnableLocalization = false;
// ** First request uses the current user's account to load sitemap file, so elevate.
SPSecurity.RunWithElevatedPrivileges(delegate()
{
SiteMapNode listNode = e.Provider.RootNode.ChildNodes[0].Clone();
listNode.Url = "http://some url";
listNode.Title = "Some title";
listNode.ChildNodes = new SiteMapNodeCollection();
SiteMapNode pageTitleNode = new SiteMapNode(e.Provider, Guid.NewGuid().ToString());
pageTitleNode.Title = "Some sub title";
listNode.ChildNodes.Add(pageTitleNode);
pageTitleNode.ParentNode = listNode;
});
return pageTitleNode;
}
I have checked that the event handler is never invoked by adding trace logging to the method as well as breakpoints.