Thursday, August 18, 2011

sharepoint 2010 + item event receivers + session

I've been googling for last couple of hours for the correct post.

"How to use sessions in sharepoint item event handlers"

finally I could find the correct link(see below). Thanks to the author.

In a nut shull, it is available in synchronous events (adding, updating).
Not available in Async events (Added, Updated).

define a variable in receiver class, assign the HttpContext.Current in default constructor.


HttpContext hContext = null;

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


public override void ItemAdding(SPItemEventProperties properties)
{
hContext.Response.Redirect(“http://microsoft.com”)
}



http://blogs.msdn.com/b/sowmyancs/archive/2008/03/25/can-we-get-the-httpcontext-in-custom-event-handlers-in-sharepoint.aspx

No comments:

Post a Comment