How does SharePoint 2013 obtain the list of "SharePoint Applications" in the "application directory" corresponding to the current site?

Source: Internet
Author: User

At first, I used the following method to traverse all site collections in the Web application of the current site ), search for the website set with the template "appcatalog" and find the list with the function marked as "0ac11793-9c2f-4cac-8f22-33f93fac18f2" under its root site.

This list is the "applicable to SharePoint Applications" list under "application directory.

public static SPList GetCorporateCatalog(SPWeb web) {    //SPSite site = GetSiteByWebTemplateId(18, current.Site.WebApplication);    SPSite site = GetSiteByWebTemplate("APPCATALOG", web.Site.WebApplication);    SPList list = GetListByTemplateFeatureId("0AC11793-9C2F-4CAC-8F22-33F93FAC18F2", site.RootWeb);    return list;}public static SPList GetListByTemplateFeatureId(string templateFeatureId, SPWeb web) {    foreach (SPList list in web.Lists) {        if (string.Equals(list.TemplateFeatureId.ToString(), templateFeatureId, StringComparison.OrdinalIgnoreCase)) {            return list;        }    }    return null;}public static SPSite GetSiteByWebTemplateId(int webTemplateId, SPWebApplication webApplication) {    foreach (SPSite site in webApplication.Sites) {        if (site.RootWeb.WebTemplateId == webTemplateId) {            return site;        }    }    return null;}public static SPSite GetSiteByWebTemplate(string webTemplate, SPWebApplication webApplication) {    foreach (SPSite site in webApplication.Sites) {        if (string.Equals(site.RootWeb.WebTemplate, webTemplate, StringComparison.OrdinalIgnoreCase)) {            return site;        }    }    return null;}

When I reviewed the code, my colleagues said this method was too inefficient. So I guess there must be a place where the "application directory" and "applicable to SharePoint Applications" are stored. The following method is available:

static readonly Guid CorporateCuratedGallerySettingsFeatureID = new Guid("F8BEA737-255E-4758-AB82-E34BB46F5828");public static SPList GetCorporateCatalog(SPWeb web) {    SPFeature settingsFeature = web.Site.WebApplication.Features[CorporateCuratedGallerySettingsFeatureID];    Guid hostSiteId = new Guid(settingsFeature.Properties["__AppCatSiteId"].Value);    Guid hostListId = new Guid(settingsFeature.Properties["__AppCatListId"].Value);    using (SPSite hostSite = new SPSite(hostSiteId))    using (SPWeb hostWeb = hostSite.RootWeb) {        SPList corporateCatalog = hostWeb.Lists[hostListId];        return corporateCatalog;    }}

It turns out that there is a feature in the Web application named corporatecuratedgallerysettings, And the identifier (ID) is "F8BEA737-255E-4758-AB82-E34BB46F5828 ". It has two attributes: "_ appcatsiteid" and "_ appcatlistid", respectively storing the "application directory" identifier (website set ID) and the list ID for the SharePoint application ).

O (distinct _ distinct) O ~~ If you can understand and use it, take it for fun.

How does SharePoint 2013 obtain the list of "SharePoint Applications" in the "application directory" corresponding to the current site?

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.