No SPContext for Event Receiver

I have some common methods that use SPContext. I am having problem when I call those methods in my event receiver code. I don't think there is a way to use SPContext in event receiver. To get it working, I have to create an overload method that takes addiational parameters such as SPWeb or SPSite depending on what is needed.

Comments

Will it work, if you override ContextEvent() method of receiver?hp
Jon said…
You can get the HttpContext by creating a constructor for your event receiver. A similar method might work for getting the SPContext.

partial class MyEventReceiver : SPItemEventReceiver
{
private HttpContext hContext = null;

public MyEventReceiver() : base()
{
hContext = HttpContext.Current;
}
}

Popular posts from this blog

SharePoint 2013 App Details Page Error

SharePoint 2013 - Working with Display Template for Content Search Web Part

Add spell check dictionary in SharePoint 2010, SharePoint 2013, and Office 365