I needed to swap the default page for new one with different webparts.
Obviously change the site definition template was out of the question.
And naturally finding out why this:
SPFile standardDefaultPage = curWeb.GetFile(SHAREPOINTDEFAULTPAGE);
SPFile newDefaultPage = curWeb.GetFile(MYSITENEWDEFAULTPAGE);
standardDefaultPage = newDefaultPage
does not work, just made no sense. Then I realized that sharepoint sometimes knows the default page even if its renamed.
So then I tried this.
The procedure is called from a custom feature activated in the My Site creation.
const string SHAREPOINTDEFAULTPAGE = "default.aspx";
const string MYSITENEWDEFAULTPAGE = "defaultNew.aspx";
public void SwapDefaultPages(SPFeatureReceiverProperties properties, SPWeb curWeb)
{
try
{
SPFile newDefaultPage = curWeb.GetFile(MYSITENEWDEFAULTPAGE);
newDefaultPage.CopyTo(SHAREPOINTDEFAULTPAGE, true);
}
catch (Exception ex)
{
UpdateLog(ex.Message + ex.StackTrace + ex.Source, EventLogEntryType.Error);
}
UpdateLog("done SwapDefaultPages");
}
and it worked.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment