Summary: Learn how to use the Search REST API and people picker and take advantage of app part dynamic resizing by using the app part edit mode. The sample displays an app part that retrieves information about a SharePoint user.

Provided by: Yina Arenas, Microsoft Corporation

When you deploy and start the app, you can add the Who Is? app part to a page on the host web. Figure 1 shows how the app part will appear on the page. It displays the people picker and uses the search REST API to get information about a SharePoint user.

Figure 1. The Who Is? app part displays detailed information about a SharePoint user

You can use the Web Part menu to make the app part display less information. Choose the Who is? properties link and clear the Include detail information check box.

Figure 2. Use the Web Part menu to display less information in the app part

Now the app part will only include user basic information, and it gets dynamically resized.

Figure 3. Edited app part displays only basic information about a SharePoint user

Prerequisites

This sample requires the following:

Key components

The app's AppPart project includes the following:

  • A Pages folder that contains two .aspx pages:

    • Default.aspx is the default page of the SharePoint-hosted app. This is the page that you see when you start the app from SharePoint instead of including it as an app part.

    • Part.aspx is the page that appears inside the app part.

Configure the sample

Follow these steps to configure the sample.

  1. Open the AppPart.sln file in Visual Studio 2012.

  2. In the Properties pane, change the Site URL property. This is the absolute URL of your SharePoint 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. Return to the host web of your SharePoint site. Navigate to a page that can include Web Parts.

  3. In the ribbon above the page, choose Page, Edit, Insert, App Part.

  4. Select the Who Is? app part and insert it on the page.

  5. In the ribbon, choose the Save button.

  6. Enter a valid user name in the text box so that the People Picker can resolve it.

Troubleshooting

The following table lists common configuration and environment errors that prevent the sample from running or deploying properly and ways to solve them.

Problem

Solution

Visual Studio doesn't open the browser after you press F5.

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 release

June 2013

Related content