I'd like to know if there are a way to make a redirection in an event receiver of a list itemUpdated and not updating. I need this because in my event, i create a file in a folder and of a document library and i want to redirect the user to this new item.
As the processing of the after event also fires on a different thread it is also not possible to redirect to a different page from within the after event as neither the HttpContext object from the request initiating the original operation is available nor is it guaranteed that the after event is executed before the response of the original request has been sent back to the browser.
To overcome this limitation SharePoint has additional functionality to allow synchronous execution of after events. The default is still asynchronous but you can now configure your after event explicitly to execute synchronous.
The easiest way to achieve this is to modify the elements.xml file of the feature which registers the event receiver as outlined in the following article.
In case that the event receiver is registered programmatically you can achieve the same result by setting the Synchronization property of the SPEventReceiverDefinition object to SPEventReceiverSynchronization.Synchronous
Once completed, to get the redirect functioning, you will need to do the following to get access to the Http Context in your ItemUpdated (for additional details see this blog).
Create two private global variables in your event receiver:
private HttpContext _httpContext; private static HttpContext _sHttpContext;
Get Current Http Context in the constructor
_httpContext = HttpContext.Current;
In ItemUpdating, again get a hold of the HttpContext
_sHttpContext = _httpContext
Use SPUtility.Redirect and _sHttpContext to redirect to a page of your choice.