I am tryin to override the SiteMapProvider "CurrentNavigation" in nightandday.master. I got the code to override the class, but i am not sure how i handle the deploy process. A colleague told me that there is a way to deploy that using a "Feature" in VS2010. So i created a new Feature, bound CustomSitemapProvider.cs to it, and deployed everything.. As you probably expect now.. nothing changed. Do i have to change the Deployment Type? Or am i on the completely wrong track now?

Edit: I tried that with the Feature now... I got a elements.xml:

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<Control Id="AdditionalPageHead" Sequence="90" ControlAssembly="CustomSitemapProviderFeature, Version=, Culture=neutral, PublicKeyToken=841c5c559877013a" ControlClass="CustomSitemapProviderFeature.CustomSitemapProvider"/>

And just a "Test Feature"..:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.UI.WebControls;

namespace CustomSitemapProviderFeature
    class CustomSitemapProvider : WebControl

        protected override void OnLoad(EventArgs e)
            string helloAlert = "alert('Hello, world!');";
            this.Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "popup", helloAlert, true);
            Label lab = new Label();
            lab.Text = "TEST";



Well .. I am able to deploy that... but nothing happens... I am not able to run my code through a Feature... My plan is to override the whole SitemapProvider through such a class..

1 Answer 1


I haven't found a way to deploy a custom sitemap provider as a SharePoint feature.

I created an empty class library project in Visual Studio, added there my public class extending PortalSiteMapProvider, made the DLL available in the GAC, and manually added this line in the web.config file of the SharePoint web application, inside the <sitemap><providers> block:

<add name="CustomSiteMapProviderName" NavigationType="Current" type="_Fully qualified class name_, _Class library name without the dll extension_, Version=, Culture=neutral, PublicKeyToken=_The key token for the dll_" />

In your class you need to override these two methods:

  • GetChildNodes - Here is where your custom business logic goes.
  • Initialize - To specify the name which will be used to identify your custom provider in the SiteMap.Providers collection. Something like this:

    public override void Initialize(string name, System.Collections.Specialized.NameValueCollection config)
        if (config == null)
            throw new ArgumentNullException("config is null");
        if (String.IsNullOrEmpty(name))
            name = "CustomSiteMapProviderName";
        if (string.IsNullOrEmpty(config["description"]))
            config.Add("description", "Brief description");
        base.Initialize(name, config);

And then you can use your new provider in any navigation control.

  • Thank you Xavier for your answer but i really need a deployable solution for this.. Oct 11, 2011 at 13:01
  • Me too... so I kept looking, and today I found this: msdn.microsoft.com/en-us/library/ff649108.aspx It explains how to register the new provider in the section Configuring and Registering the Site Map Provider, by using the SPWebConfigModification class. Oct 11, 2011 at 16:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.