Saturday, August 22, 2015

SharePoint 2013: Hello World SharePoint-hosted app

This sample has been replaced with the series of samples found at: OfficeDev/SharePoint_SP-hosted_Add-Ins_Tutorials.

The sample demonstrates how to create, package, and deploy a custom list to the appweb and a custom action to the parent web.
The JavaScript code that reads data from the parent web and the app web is located in the Home.aspx file in the BasicSharePoint-hosted directory of the BasicSharePoint-hosted project. The following screen shot shows how the Home.aspx page of the app appears after you install and launch the app.
Figure 1. Home.aspx page in the app, displaying the user, the Bing home page and a button for getting information about the appweb

Prerequisites

This sample requires the following:
  • A SharePoint development environment that is configured for app isolation.
  • Visual Studio and Office Tools for Visual Studio installed on your developer computer.

Key components of the sample

The sample app contains the following:
  • BasicSharePoint-hosted project
  • AppManifest.xml file, located in the BasicSharePoint-hosted directory
  • Home.aspx file, located in the BasicSharePoint-hosted\Pages directory, which contains the HTML and ASP.NET controls for the app’s user interface
  • App.js file, located in the BasicSharePoint-hosted\Scripts directory, which contains the JavaScript code that populates the controls in the Home.aspx file
  • Elements.xml file, located in the BasicSharePoint-hosted\HelloWorldCustomAction directory, which configures the custom action

Configure the sample

To configure the hello world SharePoint-hosted sample app, update the SiteUrl property of the solution with the URL of the home page of your SharePoint test site.

Build the sample

Press F5 to build and deploy the app.

Run and test the sample

  1. Choose Trust It on the consent page to grant permissions to the app.
  2. Choose the Get Count of Lists button to see the number of lists in the appweb.

Troubleshooting

The following table lists common configuration and environment errors that prevent the sample from running or deploying properly and how to solve them.
Problem Solution
Visual Studio does not open the browser after you press the F5 key. Set the app for SharePoint project as the startup project.
HTTP error 405 Method not allowed. Locate the applicationhost.config file in %userprofile%\Documents\IISExpress\config. Locate the handler entry for StaticFile, and add the verbs GET, HEAD, POST, DEBUG, and TRACE.




Change log

First version: July 16, 2012
Second version: March 6, 2013
Third version: January 16, 2014

Related content

No comments:

View Tenant (ULS) Logs in SharePoint Online using CSOM

Even though the classes exist in the CSOM, the Microsoft Office 365 Engineering team has confirmed that this is something which is not poss...