I want to debug our remote event receiver for a sharepoint online site collection. and since the azure service bus appraoch for debugging RER is not supported anymore. so i am trying to use the ngrok appraoch. I did these steps:-

1- Inside Visual Studio 2015 >> create new sharepoint add-in >> type provider-hosted Add-in >> I enter the url for a test enterprise wiki site collection which have the Sideloading of apps feature enabled. enter image description here

2- Then i enabled the handle Add-in installed/uninstalled:- enter image description here

3- Then inside the AppEventReceiver.svc i entered code this code + the methods implementation:-

 public SPRemoteEventResult ProcessEvent(SPRemoteEventProperties properties)
             SPRemoteEventResult result = new SPRemoteEventResult();

         switch (properties.EventType)
             case SPRemoteEventType.AppInstalled:
             case SPRemoteEventType.AppUninstalling:
             case SPRemoteEventType.ItemAdded:

         return result;
     // code goes here for the above methods implementation ..

For debugging the RER, I did these steps:-

1- I run this ngrok command:-

ngrok http --host-header=rewrite 54001// where this port is our RER port inside visual studio

2- Update the Update web.config, with the url i got from the above command:- enter image description here

3- Set the web application as Start Up project.

4- Navigate to the ngrok url where i got this page:- enter image description here

5- Register the app and update the web.config with the generated ClientId + ClientSecret enter image description here enter image description here

6- After that i run the Visual Studio project >> i got this message to trust the app:- enter image description here

7- Where the app start showing inside the site content page with a message that it is been added...

8- After that my code reached this break point:- enter image description here

9- But inside the TokenHelper.cs , I got this exception**:-

An exception of type 'Microsoft.IdentityModel.Tokens.AudienceUriValidationFailedException'
occurred in ****Web.dll but was not handled in user code 
Additional information: "localhost" is not the intended audience "f15f8358-54c4-4767-95b2-98051ed0b1c5/00af9b86.ngrok.io@8208ba41-935e-4b54-ace7-

on this code:- enter image description here

so can anyone advice on this please?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.