Export (0) Print
Expand All
1 out of 2 rated this helpful - Rate this topic

How to: Create an app event receiver

apps for SharePoint

Learn the basics about how to create a receiver and add or remove handlers for events that occur to an autohosted app for SharePoint by using the Office Developer Tools for Visual Studio 2012.

Last modified: January 29, 2014

Applies to: apps for SharePoint | Office 365 | SharePoint Server 2013

  • Visual Studio 2012

  • Office Developer Tools for Visual Studio 2012

  • Web Deploy 2.0 installed on the developer computer. You can download this tool from Web Deploy 2.0.

  • A local installation of SharePoint 2013 that has been configured to use OAuth (required for testing and debugging only). Your installation of SharePoint 2013 is already configured to use OAuth if you’re testing the app on a target website that was created from the Developer Site site definition. (You can create such a website in SharePoint 2013 Central Administration.)

Core concepts

Before you create an app event receiver, you should have a basic understanding of what apps for SharePoint are and how autohosted, provider-hosted, and SharePoint-hosted apps for SharePoint differ. You should also understand the fundamental concepts of handling events in apps for SharePoint. The following topics in Table 1 should give you that understanding.

Table 1. Core concepts for creating an app event receiver

Article title

Description

Apps for SharePoint overview

Learn how to create apps, which are small, easy-to-use solutions for end users, by using the new app model in SharePoint 2013.

Important aspects of the app for SharePoint architecture and development landscape

Learn more about the model for apps for SharePoint and aspects of its architecture, which include app hosting options, user interface options, the deployment system, the security system, and the lifecycle.

Choose patterns for developing and hosting your app for SharePoint

Learn about the different ways that you can host apps for SharePoint.

Handling events in apps for SharePoint

Learn how apps for SharePoint work and how to develop them.

Handling events in apps for SharePoint

Learn about the different types of events that you can handle in an app for SharePoint and how to implement them.

By adding an event receiver, you can handle events that occur to an app for SharePoint, as opposed to events that occur to elements such as lists or list items within an app for SharePoint.

To add an app event receiver

  1. In Visual Studio, open the project for the app for SharePoint whose events you want to handle.

  2. In Solution Explorer, choose the node for the app for SharePoint.

  3. In the Properties window, set the values of the app events that you want to handle to True. To view the Properties window, on the menu bar, choose View, Properties Window, or choose the F4 key. You can choose from the following events.

    • Handle App Installed

    • Handle App Uninstalling

    • Handle App Upgraded

    Figure 1. App events in the properties window

    App events in the properties window

    If the app for SharePoint project doesn't have a web project, which is required for handling app events or remote events, one is created for you.

  4. Add event-handling code and any support functions that you need to the AppEventReceiver.svc code file.

    For more information about the contents of the web application project and how code for app event receivers works, see Handling events in apps for SharePoint.

To add or remove app event handlers

  1. In Solution Explorer, choose the node for the app for SharePoint project.

  2. In the Properties window, set the properties for the events that you want to handle to True, and set the properties for the events that you don’t want to handle to False.

    For example, if you want to respond whenever the app for SharePoint is upgraded, set the Handle App Upgraded property to True. Set the Handle App Upgraded property to False if you don’t want to handle that event.

This topic demonstrated the basics of handling app events in an app for SharePoint. If you want to handle events that occur to items such as lists or list items within the app for SharePoint or you want to review a more detailed example that demonstrates how to handle remote events and app events together, see the following topics.

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.