Thanks. I now understand what I was doing wrong. However, I am still having some problems, likely in part b/c this is part of sharepoint. My web.config looked like this, with the custom provider set as the default:
<siteMap defaultProvider="CustomProvider" enabled="true"> <!-- CurrentNavSiteMapProvider -->
<providers>
<add name="CustomProvider" siteMapFile="_app_bin/xyz.sitemap" type="System.Web.XmlSiteMapProvider, System.Web, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
<add name="CurrentNavSiteMapProvider" description="CMS provider for Current navigation" type="Microsoft.SharePoint.Publishing.Navigation.PortalSiteMapProvider, Microsoft.SharePoint.Publishing, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" NavigationType="Current" EncodeOutput="true" />
</providers>
</siteMap>
I changed my code in global.asax to this:
SiteMapProvider customSiteMapProvider = SiteMap.Providers["CustomProvider"];
customSiteMapProvider.SiteMapResolve += new SiteMapResolveEventHandler(Handle);
It all works fine. but if I change my default provider to CurrentNavSiteMapProvider, then my global.asax throws this exception in the Handle() code:
System.InvalidCastException: Unable to cast object of type 'System.Web.SiteMapNode' to type 'Microsoft.SharePoint.Publishing.Navigation.PortalSiteMapNode'.
I put some logging code inside my Handle method:
SiteMapNode currentNode = SiteMap.CurrentNode;
HttpContext.Current.Trace.Write("SiteMapProvider = " + currentNode.Provider.Name);
The site map provider that is always listed is the default sitemapprovider, regardless of which sitemapprovider i attached the event handler to.
Just added some more logging and found out something interesting. currentNode.Provider.Name yields the default provider, but e.Provider (from SiteMapResolveEventArgs e) yields the custom provider. Not sure what this means....
Thus, it appears as if the event handling code is still attached to the default (sharepoint) provider. Any ideas?
Thanks