I am writing a feature receiver. At first I create some pages in "Site Pages" Library on feature activation and further I try to set one of the recently created page as Welcome page. But on deployment of the feature all works as intended except the welcome page. It remains the default "Home.aspx" under "Site Pages". The site where I deploy my feature is not a publishing site. Any specific reason?
Here is my sample code
public void SetHomePage(SPWeb web, string path)
{
try
{
if (PublishingWeb.IsPublishingWeb(web))
{
PublishingWeb publish = PublishingWeb.GetPublishingWeb(web);
SPFile file = web.GetFile(path);
publish.DefaultPage = file;
publish.Update();
web.Update();
}
else
{
web.RootFolder.WelcomePage = path;
web.RootFolder.Update();
}
}