SharePoint App Remote Event Receivers

Source: Internet
Author: User
Tags requires

When we use the app, we will find some problems, such as the site deployment, update or uninstall, we are very concerned about whether our app is used, this requires remote event receiver.

1. Select the mouse on the solution of our test app, press F4 pop-up property, select the processing application we need, check true, and VS will automatically create a solution that lets us write the relevant code for the remote event receiver.

2, in the creation of the remote event receiver solution, open the SVC code, and then add our code (attached), to determine if the event that triggered the installation of the app, in a appinstalllog list to insert an installation record.

3, after the code, the code is very simple, improve the permissions to write the list library, not much to say; after writing the code, publish the Web site to the server's IIS directory;

if (properties. EventType = = spremoteeventtype.appinstalled)
{
    spsecurity.runwithelevatedprivileges (delegate ()
    {
        using (SPSite site = new SPSite ("http://url:2014"))
        {
            using (SPWeb web = site. OpenWeb ())
            {
                SPList list = web. lists["Appinstalllogs"];
                SPListItem item = list. Items.Add ();
                item["title"] = "Sp2013picturewallapp";
                item["Log"] = "Sp2013picturewallapp to" + DateTime.Now.ToString () + "has been installed. ";
                Item. Update ();}}
    );
}

4, in the app solution, find the Appmanifest.xml file, right-click to view the code, modify the Installedeventendpoint as we previously released the site of the Svc file directory;

5, we add our app in a site, and then look at the Appinstalllogs list library, found that an installation log has been written, indicating that the remote event receiver development deployment was successful.

Concluding remarks

The above describes the process of triggering an event to write to the installation log during the app installation process, in fact, remote event receivers can also do a richer job, such as event triggers in a SharePoint solution, add events to a list or document library in an app, which requires us to create remote Event Receiver solution.

Special Recommendations

The idea of the above is referenced from the Microsoft SharePoint app Development book, the simple look at the table of contents, the introduction of APP development is very good, recommend to everyone.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.