|
1 | 1 | ---
|
2 | 2 | title: Handle add-in events in the provider-hosted add-in
|
3 |
| -ms.date: 10/31/2017 |
| 3 | +description: Customize the installation of a provider-hosted SharePoint Add-in by configuring the solution for event receiver debugging, creating the installation and uninstallation handlers, running the add-in, and testing the handlers. |
| 4 | +ms.date: 11/02/2017 |
4 | 5 | ms.prod: sharepoint
|
5 | 6 | ---
|
6 | 7 |
|
7 | 8 | # Handle add-in events in the provider-hosted add-in
|
8 | 9 |
|
9 |
| -Learn how to customize the installation of a provider-hosted SharePoint Add-in. |
10 |
| - |
11 |
| -> [!NOTE] |
12 |
| -> The name "apps for SharePoint" is changing to "SharePoint Add-ins." During the transition, the documentation and the UI of some SharePoint products and Visual Studio tools might still use the term "apps for SharePoint." For details, see [New name for apps for SharePoint](new-name-for-apps-for-sharepoint.md). |
13 |
| -
|
14 | 10 | This is the seventh in a series of articles about the basics of developing provider-hosted SharePoint Add-ins. You should first be familiar with [SharePoint Add-ins](sharepoint-add-ins.md) and the previous articles in this series:
|
15 | 11 |
|
16 | 12 | - [Get started creating provider-hosted SharePoint Add-ins](get-started-creating-provider-hosted-sharepoint-add-ins.md)
|
@@ -48,13 +44,12 @@ For the Chain Store add-in, we combine these strategies. In this article, you cr
|
48 | 44 |
|
49 | 45 | In a later article in this series, you'll put first-run logic in the **Page_Load** method of the add-ins start page. This logic deploys the two custom lists and does some other things, too.
|
50 | 46 |
|
51 |
| -## Configure the solution for event receiver debugging |
52 | 47 | <a name="RERDebug"> </a>
|
| 48 | +## Configure the solution for event receiver debugging |
53 | 49 |
|
54 | 50 | Debugging of event receivers requires the use of the Azure Service Bus. Follow the instructions at [Debug and troubleshoot a remote event receiver in a SharePoint Add-in](debug-and-troubleshoot-a-remote-event-receiver-in-a-sharepoint-add-in.md). Because you are using a SharePoint Online website as your test site, ensure that you carry out the instructions for a remote test site. The remainder of this series assumes you have configured debugging successfully.
|
55 | 51 |
|
56 | 52 | ## Create the installation handler
|
57 |
| -<a name="RERDebug"> </a> |
58 | 53 |
|
59 | 54 | > [!NOTE]
|
60 | 55 | > The settings for Startup Projects in Visual Studio tend to revert to defaults whenever the solution is reopened. Always take these steps immediately after reopening the sample solution in this series of articles:
|
@@ -150,7 +145,7 @@ Debugging of event receivers requires the use of the Azure Service Bus. Follow t
|
150 | 145 |
|
151 | 146 | 9. Add the following **using** statements to the top of the file.
|
152 | 147 |
|
153 |
| - ``` |
| 148 | + ```C# |
154 | 149 | using System.Data.SqlClient;
|
155 | 150 | using System.Data;
|
156 | 151 | using ChainStoreWeb.Utilities;
|
@@ -180,7 +175,6 @@ Debugging of event receivers requires the use of the Azure Service Bus. Follow t
|
180 | 175 | This method creates a row in a database table called **Tenants**. In addition to the **Name** column, the table also has a **Version** column with a default value set to 0000.0000.0000.0000. In a later article in this series, you will create first-run logic that looks at this value to determine whether the add-in has already been installed on the host web. If the version is 0000.0000.0000.0000, your code deploys the **Local Employees** and **Expected Shipments** lists, and then raises the version number.
|
181 | 176 |
|
182 | 177 | ## Create the uninstallation handler
|
183 |
| -<a name="RERDebug"> </a> |
184 | 178 |
|
185 | 179 | It is usually a good practice to handle the uninstalling event whenever you are handling the installed event. The basic idea is that the uninstalling handler deletes or recycles things that the installed handler deployed. There are, however, many exceptions, so you really need to understand the use cases of your add-in. For example, a list that is deployed with an add-in and populated with the add-in might still have value even after the add-in itself is uninstalled, in which case you wouldn't want to uninstall the list in the uninstalling event handler.
|
186 | 180 |
|
@@ -233,17 +227,16 @@ The uninstallation event does not run, as you might expect, when a user removes
|
233 | 227 | > In an earlier article in this series, you configured the project to rebuild the corporate database each time you select F5. This empties the **Tenants** table.
|
234 | 228 |
|
235 | 229 | ## Run the add-in and test the installation handler
|
236 |
| -<a name="RERDebug"> </a> |
237 | 230 |
|
238 | 231 | 1. Use the F5 key to deploy and run your add-in. Visual Studio hosts the remote web application in IIS Express and hosts the SQL database in SQL Express. It also makes a temporary installation of the add-in on your test SharePoint site, runs the installation event handler, and immediately runs the add-in. You are prompted to grant permissions to the add-in before its start page opens.
|
239 | 232 |
|
240 | 233 | 2. When the add-in's start page opens, select the gear icon on the chrome control at the top, and then select **Account settings**.
|
241 | 234 |
|
242 |
| -3. On the **Accounts** page, select the **Show Add-in Version** button. The version shows as 0000.0000.0000.0000. |
| 235 | +3. On the **Accounts settings** page, select the **Show Add-in Version** button. The version shows as 0000.0000.0000.0000. |
243 | 236 |
|
244 |
| - *Figure 1. Accounts page* |
| 237 | + *Figure 1. Account settings page* |
245 | 238 |
|
246 |
| -  |
| 239 | +  |
247 | 240 |
|
248 | 241 | 4. To end the debugging session, close the browser window or stop debugging in Visual Studio. Each time that you select F5, Visual Studio retracts the previous version of the add-in and installs the latest one.
|
249 | 242 |
|
|
0 commit comments