2

I created a simple hello world sharepoint hosted app based on the template in Visual Studio 2012. I added nothing. When I hit F5 it works but when I publish and add it to my App Catalog and try to add it to Site, it first asked whether trust it, (I hit "trust it") and then I shows "The page can't be displayed, make sure web address is correct, blah blah ". What is different when you hit F5 and when you publish a SP app? When you hit F5 the url begins with

   http://app-9393939394.myappdomain/.... 

but when you publish it the url looks like

   http://mySPsite/_layouts/15/.....

thanks for your advice, I appreciate it.

1
  • I am facing exactly the same problem. Deploying app from visual studio works fine. But when deployed from appcatalog it gives 404. Analyzing it further shows windows hosts file is not modified in case of app catalog deployment.. Sep 5, 2013 at 12:08

1 Answer 1

8

In terms of where and how your app is ultimately deployed, there is actually no difference between pressing F5 in Visual Studio and installing the app from the App Catalog.

When you press F5 in your Visual Studio App for SharePoint project, Visual Studio will open your browser to one of the following URLs:

 http://[host web URL]/_layouts/15/viewlsts.aspx  (no app permissions requested)
 http://[host web URL]/_layouts/15/appInv.aspx... (app permissions requested)

This will show your app in the Site Contents list (you can also access this link from the quick launch or Site Actions menu on your SharePoint site). This is also the URL where you will be taken after you add an app from the App Catalog. If you try to click the link for your app, however, you will see the URL is in this format:

 http://[host web URL]/_layouts/15/appredirect.aspx?instance_id={GUID}

With apps for SharePoint, there are two SPWebs involved: the host web and the app web. The host web is the SPWeb where the user installs the app, and the app web is the SPWeb that contains an app instance's isolated storage (for any internal resources the app may provision such as lists, HTML/CSS/JS assets, etc.) For security reasons, your app web should be located on a separate app domain that is different from the domain where SharePoint is installed.

The appredirect.aspx page, as the name suggests, will redirect you to the Start Page you specify in your app's AppManifest.xml file, which is in the format:

 http://[app prefix][app hash].[app domain]/[relative site URL]/[app name]/Pages/Default.aspx

If you are getting a 404 error when trying to acceess the app's start page, it is because you have to do some IT pro work to configure the app domain so that everyone can access pages in the app domain. This involves setting up the app domain in DNS and creating a forward lookup zone and a CNAME alias (because each app web's URL will contain a unique hash). These steps are described in detail in this TechNet article.

1
  • in regards to the 404 error you are mentioning: I have been altering my hosts file during development to access the isolated app domain. It's been working, however recently the sharepoint hosted app has been giving a literal 404 error, not a domain lookup error, where it works fine while running the Visual Studio debugger (F5). Any ideas to troubleshoot? Apr 19, 2013 at 16:53

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.