This sample has been moved to SharePoint-Add-in-REST-OData-CrossDomain. The description below may not exactly match the new version.


Summary: Learn how to use the cross-domain library in apps for SharePoint to read items in a list that is hosted in the app web.

Last modified: May 28, 2014

In this article
Description of the sample
Prerequisites
Key components of the sample
Configure the sample
Run and test the sample
Troubleshooting
Change log
Related content

This sample provider-hosted app demonstrates how to use the cross-domain library in SharePoint 2013 to read the items in an announcements list in the app web. The app deploys an announcements list to the app web, and the remote web page displays the title and body of each announcement by using the Representational State Transfer (REST) service.

Description of the sample

The code that uses the cross-domain library is in the CrossDomainCall.aspx file of the CrossDomainWeb project. Figure 1 shows the CrossDomainCall.aspx page of the app after you install and run the app.

Figure 1. Browser window after running the solution

 

Prerequisites

This sample requires the following:

  • Microsoft Visual Studio 2012

  • Office Developer Tools for Visual Studio 2012

  • A SharePoint 2013 development environment (app isolation required for on-premises scenarios)

    For more information, see Get started developing apps for SharePoint.

Key components of the sample

The sample contains the following:

  • CrossDomainApp project, which contains the AppManifest.xml file

  • CrossDomainWeb project

    • CrossDomainCall.aspx file, which contains references to SharePoint JavaScript resource files

    • Web.config file

Configure the sample

Follow these steps to configure the sample.

  • Update the SiteUrl property of the solution with the URL of the home page of your SharePoint website.

Run and test the sample

 

  1. Press F5 to build and deploy the app.

  2. Choose Trust It on the consent page to grant permissions to the app.

  3. You should see an HTML page displaying five announcements.

Troubleshooting

For troubleshooting steps, visit the Troubleshooting the solution table in the cross-domain library documentation article.

Change log

  • First version: July 2012

  • Updated version: October 2013. Changed the start page of the project to an ASPX page that works better with provider-hosted apps.

  • 2nd version: May 2014

Related content