SharePoint : SPWeb.AlternateHeader issue – does not accept empty “” string

Recently I see this problem in SPWeb object. I have configured the alternate header in the onet.xml. I created the sites. Now I want to revert back the alternate header configured and set it to empty. As we know already, what ever the modification made on the onet.xml will be picked up by the newly created sites but not by the sites existing. So I decided to use the SPWeb.AlternateHeader. property. But unfortunately that doesn’t work. It accepts all the values except the empty string “”, or null values.

 

The following code don’t work

 

            SPWeb web = new SPSite(https://karthickmain::8081/sites/test1).OpenWeb();

            web.AlternateHeader = “”;

            web.Update();

 

Note: The following workarounds are not supported by Microsoft

 

Workaround # 1:

            The webs table of <portal>_SITE contains the AlternateHeader value of the site. Open the table and modify the value

           

            This way you modified the alternate header for existing sites. But however still the API wont work.

 

Workaround #2:

            When you set the web.AlternateHeader=””, and call the web.Update() method, the stored procedure proc_UpdateTpWebMetaData of <portal>_SITE database is being called. Open this stored procedure in the Enterprise manager. You will find the following the checking happens.

 

AlternateHeaderUrl = CASE WHEN @AlternateHeaderUrl IS NULL

                                  THEN AlternateHeaderUrl

                                  ELSE @AlternateHeaderUrl END,

 

Change this to

 

AlternateHeaderUrl = @AlternateHeaderUrl END,

 

 

            This way you have modified the stored proc, then rerun the code to modify the AlternateHeader.