Unlike “Before” event (e.g. ItemAdding, ItemDeleting) “After” events (e.g. ItemAdded, ItemDeleted) in SharePoint usually fire asynchronously on a different thread then the http request.
That means that the HttpContext and HttpRequest objects cannot be retrieved in these events as they do not exist on the current stack.
That means that there is no way to directly retrieve querystring parameters or other values like http headers inside these “After” events.
A simple workaround for this problem is to retrieve the relevant information inside the “before” event and pass it to the “after” event using the HttpRuntime cache:
public override void ItemAdding(SPItemEventProperties eventProperties)
public override void ItemAdded(SPItemEventProperties eventProperties)
Does not work under Sandbox. HttpContext.Current is null in sandbox event receivers.
It Really Works!! Thanks for the post! 🙂