views:

108

answers:

1

I've added a feature to my onet.xml file which gets activated whenever a site gets created. However, that feature needs to know the url of the site being created. I thought I could figure that out from the current SPContext within the activation event of the feature, but when I created the site I got a null reference on SPContext.Current.

Is that to be expected, or have I done something wrong? If that is the case, does anyone have any suggestions how I can dynamically learn the URL of the site being created?

Thanks

+3  A: 

It seems like you have created a feature receiver? They don't use SPContext but find the site they have been activated on through the properties, like so:

    public override void FeatureActivated(SPFeatureReceiverProperties properties)
    {
        using (SPWeb web = properties.Feature.Parent as SPWeb)
        {...}
    }
ArjanP