- SharePoint Online and on-premise SharePoint 2013 and later
This sample requires the following:
A SharePoint 2013 (or later) development environment that is configured for add-in isolation. (A SharePoint Online Developer Site is automatically configured. For an on premise development environment, see Set up an on-premises development environment for SharePoint Add-ins)
Visual Studio and the Office Developer Tools for Visual Studio installed on your developer computer
Description of the code
The page looks similar to the following.
Note: The start page of the add-in, CrossDomainCall.aspx, is a plain HTML file. It has an "aspx" extension because when a remote start page in a provider-hosted add-in is opened by SharePoint, SharePoint sends it a context token in the body of the HTTP request. To do this SharePoint must send a POST request. But the IIS Express that is hosting the remote page when you are debugging will not accept POST requests to a resource with a .html extension.
The sample demonstrates the following:
How to use the key classes of the CDL to make calls from a remotely hosted domain to the SharePoint add-in web domain.
How to parse the JSON-formatted data returned from the SharePoint and how to display it dynamically.
To use the sample
- Open Visual Studio as an administrator.
- Open the .sln file.
- In Solution Explorer, highlight the SharePoint add-in project and replace the Site URL property with the URL of your SharePoint developer site.
- Press F5.
- After the add-in installs, the consent page opens. Click Trust It.
For troubleshooting steps, visit the "Troubleshooting the solution" table in the cross-domain library documentation article.
Questions and comments
We'd love to get your feedback on this sample. You can send your questions and suggestions to us in the Issues section of this repository.
- SharePoint Add-ins
- Creating SharePoint Add-ins that use the cross-domain library
- Access SharePoint 2013 data from add-ins using the cross-domain library
Copyright (c) Microsoft. All rights reserved.