An Error Occurred While Processing your request – SharePoint Office 365 with Provider Hosted Application

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

We saw many Exceptions, warnings, step by step procedures to create a SharePoint Provider Hosted Applications in the earlier articles. But, still, there are so many exceptions, facing in the real world. Obviously, those mistakes are the simple steps which we are missing, or doing wrong.

In that scenario, today I was creating a new PHA and faced the strange exception as below.

An Error Occurred while processing your request.




There are many root causes for this issue. But, today the new thing I have done is, hosting the APP Web in an Azure VM with a Public IP, so that my APP will be loaded from the internet.

So in that case, I verified the Client ID,, Client Secret ID, permissions for the Directory Browsing, Permissions for the APP, everything is fine.

The APP is redirecting to the Default.aspx as well.

Then, the Exception Occurs from the below method.

 protected void Page_PreInit(object sender, EventArgs e)
             Uri redirectUrl;
             switch (SharePointContextProvider.CheckRedirectionStatus(Context, out redirectUrl))
                 case RedirectionStatus.Ok:
                 case RedirectionStatus.ShouldRedirect:
                     Response.Redirect(redirectUrl.AbsoluteUri, endResponse: true);
                 case RedirectionStatus.CanNotRedirect:
                     Response.Write("An error occurred while processing your request.");

If we debug the CheckRedirectionStatus method, it will be going to the TokenHelper.cs, in which we are not supposed to do any changes.

But, always the method returns to the third switch case. That is, CanNotRedirect.

Hence, I wanted to dig a bit further and just saw the fiddler Logs.


The Exception which I was getting is,


Hence, if we saw the exception, The end points were not matching. This is because, during the APP registration, the Domain which we entered is not the correct one.

1. Go to _Layouts/15/appinv.aspx. Enter the Client ID and do the lookup.


2. Verify, whether the App Domain and the Redirect URL are matching. In my case, it is not matching.

3. The App Domain was given like But the Redirect URL is having a full path of******

4. So, we need to update this APP. SharePoint does not allow us to update the APP. Rather, we can register a new app by going to appregnew.aspx and get a new Client ID, Client Secret ID.

The new values should be


5. Update our APP with the new IDs and Increment the Version.

6. Upload to the AppCatalog

7. Remove the Current app from the site and add it back from the app catalog.

8. Launch the APP.

9. Hurray!!! It works.


A simple mistake, which took about two hours to identify the root cause and a solution.


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