Skip to content

Instantly share code, notes, and snippets.

@hemache
Created May 8, 2016 11:44
Show Gist options
  • Save hemache/b0895763c486a12814dc72a29209626f to your computer and use it in GitHub Desktop.
Save hemache/b0895763c486a12814dc72a29209626f to your computer and use it in GitHub Desktop.
public override void FeatureActivated(SPFeatureReceiverProperties properties)
{
SPWeb web = properties.Feature.Parent as SPWeb;
web.AllowUnsafeUpdates = true;
try
{
f(Microsoft.SharePoint.Publishing.PublishingWeb.IsPublishingWeb(web))
{
var publishingWeb = Microsoft.SharePoint.Publishing.PublishingWeb.GetPublishingWeb(web);
foreach(SPListItem item in publishingWeb.PagesList.Items)
{
if(item.File.Name == "Home.aspx")
{
publishingWeb.DefaultPage = item.File;
break;
}
}
publishingWeb.Update();
}
}
finally
{
web.AllowUnsafeUpdates = false;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment