Step By Step Procedures to Add a Remote Event Receivers (RER) in SharePoint Office 365 – A simplest Way

Sathish Nadarajan
Solution Architect
January 30, 2017
Rate this article
[Total: 0    Average: 0/5]

I have been seeing many developers, who is really scary about creating the Remote Event Receivers. But actually the RER are very useful utilities and it can be customized for many things. So thought of making it as simple as It could be.

Let us see the Process Step by Step.

1. Before start reading, I assume that all of us gone through the Earlier Article HERE.

2. If not, I strongly suggest that, as this will be a continuation from that.

3. Now, one more important URL we need to go through is, how to attach an Event Receiver.

4. Basically, I am going to update the app web alone.

5. And by using a small piece of EXE, we will attach the remote event receiver with the List.

6. Now, for our reference, the initial Structure of the APP which we created in the earlier article will be like this.



7. The source code can be downloaded at the provided link at the end.

8. Add a folder called Services.




9. Add a Txt file and Rename it as “Validation.svc”

10. Right Click and “View Markup”




11. Edit the Markup as below.

 <%@ ServiceHost Language="C#" Debug="true" Service="Office365.PHA.OnPrem.APPWeb.Services.Validation" CodeBehind="Validation.svc.cs" %>

12. Rebuild the solution.

13. That’s it. Now, let us add the remote event receiver to a List in the Site.

14. For that, we are already seen that in a different article. For our reference, the code would be,

 using (var ctx = authMgr.GetSharePointOnlineAuthenticatedContextTenant(siteUrl, userName, password))
                 Web web = ctx.Web;
                 List myList = web.Lists.GetByTitle("MyList");
                 #region Attach Document Item Created Event Receiver
                 var receiver = new EventReceiverDefinitionCreationInformation();
                 receiver.EventType = EventReceiverType.ItemAdded;
                 receiver.ReceiverUrl = new Uri("http://office365pha/Office365.PHA.OnPrem.APPWeb/Services/Validation.svc").AbsoluteUri;
                 receiver.ReceiverName = "MyItemAddingEvent2";
                 receiver.Synchronization = EventReceiverSynchronization.Asynchronous;

15. The Web.Config would be like below.

 <?xml version="1.0" encoding="utf-8"?>
   For more information on how to configure your ASP.NET application, please visit
     <authentication mode="None" />
     <customErrors mode="Off"></customErrors>
     <httpRuntime targetFramework="4.5"/>
   <location path="Services">
         <allow users="*" />
       <compiler language="c#;cs;csharp" extension=".cs"
         type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
         warningLevel="4" compilerOptions="/langversion:6 /nowarn:1659;1699;1701"/>
       <compiler language="vb;vbs;visualbasic;vbscript" extension=".vb"
         type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
         warningLevel="4" compilerOptions="/langversion:14 /nowarn:41008 /define:_MYTYPE=\&quot;Web\&quot; /optionInfer+"/>
     <add key="ClientId" value="***********" />
     <add key="ClientSecret" value="***************" />
         <binding name="secureBinding">
           <security mode="Transport" />
         <!--Used by SharePoint Add-in-->
         <binding name="secureBinding1">
           <security mode="Transport" />
         <!--Used by SharePoint Add-in-->
         <binding name="secureBinding2">
           <security mode="Transport" />
       <add binding="basicHttpBinding" scheme="https" bindingConfiguration="secureBinding2" />





Happy Coding,

Sathish Nadarajan.

Author Info

Sathish Nadarajan
Solution Architect
Rate this article
[Total: 0    Average: 0/5]
Sathish is a Microsoft MVP for SharePoint (Office Servers and Services) having 13+ years of experience in Microsoft Technologies. He holds a Masters Degree in Computer Aided Design and Business more

Leave a comment