I am installing a sub-site in Sharepoint 2010 using PowerShell. For all the sub-sites, we have configured sharepoint to launch a particular sub-site's default.aspx page as landing page after log-in. For my use case, I want override this behavior by launching a page being created as a part of a Feature used in this sub-site. I am doind so by using following code in Feature's EventReciever.cs :
public override void FeatureActivated(SPFeatureReceiverProperties properties)
{
using (var currentWeb = properties.Feature.Parent as SPWeb)
{
if (currentWeb != null)
{
var root = currentWeb.RootFolder;
if (root != null)
{
root.WelcomePage = @"Management\Pages\LandingPage.aspx";
root.Update();
}
//this.AddNavigationNodes(currentWeb);
}
}
base.FeatureActivated(properties);
}
The code doesn't work until either I click on the title of the site (on top left), or enable and then re-enable the feature. Seems like code needs some kind of triggering event. Am I doing something wrong? Please help...