1

I'm seeing something weird happening in my provider hosted app. When deploying the app via Visual Studio, the output says:

App was installed at https://app-bebd3cad51d715.repsajapps.com/sites/devcenter/Test_PHApp/.

Okay, fine. So now I open up my SharePoint dev site, click on the app and my app is opened. But... the JSOM calls I put in there are failing. I started bugfixing and found out that the URL to my app looks like this:

https://testapp.repsajweb.com/?SPHostUrl=https%3A%2F%2Fportal%2Erepsajdev%2Ecom%2Fsites%2Fdevcenter&SPLanguage=en%2DUS&SPClientTag=0&SPProductNumber=15%2E0%2E4641%2E1000&SPAppWebUrl=https%3A%2F%2Fapp%2Dcc98c8ad51d714%2Erepsajapps%2Ecom%2Fsites%2Fdevcenter%2FTest%5FPHApp

Let's take a closer look at that SPAppWebUrl querystring parameter and decode it:

https://app-cc98c8ad51d714.repsajapps.com/sites/devcenter/Test_PHApp

Hey... huh... it's a different one as where the app was originally deployed to? When browsing it, SharePoint says:

Cannot find site for request 'https://app-cc98c8ad51d715.repsajapps.com/_login/default.aspx?ReturnUrl=/sites/devcenter/Test_PHApp/_layouts/15/Authenticate.aspx?Source=%252Fsites%252Fdevcenter%252FTest%255FPHApp&Source=/sites/devcenter/Test_PHApp'.

Which seems legit since the app was deployed somewhere else.

So the question now is; why the heck would it include a different URL in the querystring, pointing to a site which does not exist?

Update: from the URL to the app, I got the app instance id. That can be used to retrieve the app instance using Get-SPAppInstance in Powershell. The instance has a AppWebFullUrl property which points to the correct URL (the one from VisualStudio).

Update 2: I removed and rebuilt my developer site, which didn't help. It seems the URL being used for the appweb changed, but it still point to a site which doesn't. I also tried a simple app from the MSDN examples, which behaves exactly the same. I then tried reprovisioning the subscription and app management service applications (removing the databases), which also did not make any difference.

1 Answer 1

1

Okay. After a LOT of trial & error, I finally found out the problem.

In my ULS logs, I noticed an error stating it could not find https://portal.repsajdev.com:11978/sites/devcenter. My AAM setup of SharePoint is as follows: I have a host header web app running at 443 (SSL) and port 11978. My named site collection was runnning at https://portal.repsajdev.com/sites/devcenter and http://portal.repsajdev.com:11978/sites/devcenter. Notice a subtle difference; SharePoint was looking for https at port 11978, whilst I was running http. So the error was correct: that site didn't exist.

WHY it was searching for that URL, I have no clue. I smells like a bug, but I'm not 100% sure of that. The fix was rather simple; I changed my mapping to include an additional https endpoint on port 117979 at which I could run https://portal.repsajdev.com:11979/sites/devcenter. After redeploying my app, things magically started to work.

So whilst I still have a hard time explaining what went wrong here, I do have it fixed. Hope this might help someone in the future.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.