Sometimes we have a requirement like on feature activation or deactivation we have to change the Welcome Page(Default Page) of the publishing site.
Below is the code snippet with the help of which we can change the Welcome Page:
public override void FeatureActivated(SPFeatureReceiverProperties properties)
{
using (SPSite objSiteProperty = (SPSite)properties.Feature.Parent)
{
using (SPWeb objSPWeb = objSiteProperty.OpenWeb())
{
PublishingWeb objPublishingWeb = PublishingWeb.GetPublishingWeb(objSPWeb);
SPFile objHomePageFile = objSPWeb.GetFile("Pages/Test.aspx");
objPublishingWeb.DefaultPage = objHomePageFile;
objPublishingWeb.Update();
}
}
}
And in the same way on Feature Deactivation we can change the Welcome Page again.
I am getting issue
ReplyDeleteCould not load type 'Microsoft.SharePoint.SPReusableAcl' from assembly 'Microsoft.SharePoint, Version=14.900.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c'.