Resolved: An unexpected error with a provider-hosted app for SharePoint

Scenario: You developed and hosted an ASP.NET  MVC site on IIS and planning to consume this provider-hosted app in SharePoint. When accessing standalone, the MVC site is working fine but when installing and called from SharePoint, it throws an error

An unexpected error has occurred.

Please try again by launching the app installed on your site.

Fix:

  • Open IIS and select the ASP.NET MVC site in the left panel.  In the right section, under IIS; click on Authentication. (See below screenshot).1
  • In the Authentication window, Disable Anonymous Authentication and Enable Windows Authentication. See below the screenshot. 2
  • Recycle app-pool of the ASP.NET MVC site and it will fix the error.

Happy SharePointing 🙂