Redigera

Dela via


Replace event receivers in sandbox solutions

The approach you take to handle events in SharePoint is slightly different in the SharePoint Add-in model than it was with Full Trust Code or in coded-sandbox solutions. In typical previous solutions, event receivers were created by using the SharePoint Server-Side Object Model and deployed via solutions packages, which executed the code on the SharePoint servers.

In the SharePoint Add-in model, however, the event receiver implementation executes on the web server that is hosting the event receiver; these are called remote event receivers (RERs). Event receivers can in many cases be replaced with a remote event receiver implementation.

This article describes various options and design considerations.

Note

Code-based sandbox solutions were deprecated in 2014, and SharePoint Online has started the process to completely remove this capability. Code-based sandbox solutions are also deprecated in SharePoint 2013 and in SharePoint 2016.

Options for replacing event receivers

Approach Design considerations and more information
Remote event receiver
  • Requires hosting infrastructure.
  • Hosting infrastructure must be highly available.
  • The service endpoint that hosts the remote event receiver must be configured for anonymous authentication.
  • Requires a trusted third-party certificate if you are using SharePoint Online.
  • Not intended for long running operations.
  • Remote event receivers that are attached outside the context of add-ins, attached by using a console application or PowerShell, will not receive a SharePoint context token when invoked, and you must defer to add-in-only permissions or use the SharePointOnlineCredentials class.
  • There is no retry mechanism.
Webhooks
  • Require hosting infrastructure.
  • Hosting infrastructure must be highly available.
  • Do not support synchronous events.
  • Process changes after the event has occurred.
  • Not available in SharePoint on-premises builds at this time.
Remote timer job to monitor changes
  • Uses the ChangeQuery object to monitor a site or list for modifications. This pattern is an alternative to remote event receivers.
  • Requires a hosting infrastructure.
  • Processes changes after the event has occurred.
  • Uses a polling mechanism to process changes.

Removing sandbox code from your site

When you deactivate your existing sandbox solution from your sites, any assets or files deployed by using declarative options are not removed. However, the features in the sandbox solution are automatically deactivated and the event receiver is removed.

See also