Development — August 15, 2009 10:14 pm

C#: Setting the Portal Site Connection property

Posted by

Recently a client asked to that all Site Collections that are created are automatically connected to the main corporate portal using the Portal Site Connection Setting (Site Actions -> Site Settings -> Portal Site Connection)

Portal Connection Settings

Portal Connection Settings

To do this in code is very simple as shown below which is actually triggered when a Feature gets activated:


public override void FeatureActivated(SPFeatureReceiverProperties properties)
{
using (SPSite site = properties.Feature.Parent as SPSite)
{
PortalLog.LogString("Activating feature for: " + site.PortalName + " at URL: " +   site.PortalUrl);

site.PortalUrl = "http://corporate.portal.com";
site.PortalName = "Corporate Portal";
}
}

And thats it you can now you can set this in code and maybe do what we did and attach it to various site templates.

Share and Enjoy:
  • Print
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks

No related posts.

Related posts brought to you by Yet Another Related Posts Plugin.

  • Share this post:
  • Facebook
  • Twitter
  • Delicious
  • Digg

Leave a Reply

— required *

— required *