public class Feature1EventReceiver : SPFeatureReceiver
{
public override void FeatureInstalled(SPFeatureReceiverProperties properties)
{
string sContextNull = (SPContext.Current == null) ? "Context is NULL" : "Context is OK";
string sFeatureNull = (properties.Feature == null) ? "Feature is NULL" : "Feature is OK";
// Some code here
...
...
{
}
The feature has successfully installed (without error in logs). My problem is that sContextNull always returns "Context is NULL". And sFeatureNull always returns "Feature is NULL" too. Is there a way to get not null values of SPContext.Current and properties.Feature?
Another method FeatureActivated returns Context is NULL and Feature is OK. WTF?
SPContext.Current
http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spcontext.current.aspx
Gets the context of the current HTTP request in Microsoft SharePoint Foundation.
SPFeatureReceiver.FeatureInstalled is executing when a feature is installed into a farm, which is done with a deploy/install command from stsadm or powershell, which then usually triggers the timer job to do the work. At this point there is no HTTP request, so SPContext.Current returns null.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With