A lesser known trick to make use of the HttpContext in asynchronous Event Receivers in SharePoint 2007 or SharePoint 2010 is to define a constructor on the Event Receiver class that assigns the HttpContext to an internal or private member variable. Next you can access it from the method overrides for handling events.
public class MyER1 : SPItemEventReceiver
{
// Local reference to HttpContext during Type Construction so we can use it in the Async Methods
internal HttpContext _ctx = null;
public MyER1()
{
_ctx = HttpContext.Current;
}
public override void ItemAdded(SPItemEventProperties properties)
{
string requestUrl = _ctx.Request.Url.ToString();
}
}
There’s a difference in behavior for Lists and Libraries; the former allows you to also read/write from the Context.Session, while the latter doesn’t allow this (Session is null).
I’ve (ab)used this once on a project where I’d call a custom LayoutPage called with QueryString parameters to force a SPListItem.Update(). In the Event Receiver the code would interact with the values of those parameters.
Side note:
Doubt that there’s official support on this. Feel free to drop a comment with your opinion.