I am developing a sharepoint feature which takes a backup of the site at sitecollection level and at site level whenever a user tries to delete the site. The feature is working fine without issues for the existing sitecollection and sites when the feature is activated. To give more picture, i am taking backup through code in events SiteDeleting and WebDeleting events. This events are hooked up using FeatureActivated event. I understand this ensures the event are hooked only up for the existing sites because of my code(i am hooking SiteDeleting and WebDeleting events in FeatureActivated event). After the feature activated, if i create a new site collection/sites the feature is not working(i.e backup is not taken when deleting the site).

I was trying to activate the event for new sites and hence i looked if there will be similar events like sitecreating where i can again hook up the SiteDeleting and WebDeleting events for new sites. But i came to know after some reasearch that there is no sitecreating event which can be used. After bit of googling i found that it can be done through a feature called stapling where we need to create another feature that attaches this feature to the new sites through template name. I have tried installing both the feature(my original and stapling feature) but it never seems to be working...

I am very new to SharePoint development and its taking time for fixing it. It will great if someone can help me to make the feature to work for the new sites as well.. I believe i am doing something wrong in scope parameter of feature.xml..listed below the feature.xml contents.

SiteDeletFeature (My original Feature) *Feature.xml* <

?xml version="1.0" encoding="utf-8" ?>
<Feature Title="My SharePoint Delete Feature"
         Scope ="WebApplication" 
         ReceiverAssembly="My.Sharepoint.SiteDeleteFeature, Version=, Culture=neutral, PublicKeyToken=762e98b8afce5f9b"
    <ElementManifest Location="Elements.xml"/>

SiteDeleteFeatureStapling *Feature.xml*

<?xml version="1.0" encoding="utf-8" ?>
<!-- Copyright (c) Microsoft Corporation. All rights reserved. -->
<Feature xmlns="http://schemas.microsoft.com/sharepoint/"
    Title="My SharePoint Delete Feature"
    Description="My SharePoint Delete Feature"
        <ElementManifest Location="FeatureStapling\FeatureStapling.xml" />


<?xml version="1.0" encoding="utf-8" ?>
<!-- Copyright (c) Microsoft Corporation. All rights reserved. -->
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
    <FeatureSiteTemplateAssociation Id="DA910034-F270-4932-90D0-05AE2EE13192" TemplateName="STS#0" />
    .//goes on, i have included all template names
    <FeatureSiteTemplateAssociation Id="DA910034-F270-4932-90D0-05AE2EE13192" TemplateName="MyCOMMUNITY" />

I have tried various option in Scope parameter for SiteDeleteFeatureStapling like Web,Site but nothing worked out...

Could someone help me to fix this issue?

1 Answer 1


Try changing your templatename to GLOBAL, that will take care of all of the site definitions except for the blank site, which you can include as STS#1. The stapling also doesn't work for templates. See my question here on an idea on how to get around this in SP2010: https://sharepoint.stackexchange.com/questions/3975/sp-2010-templates-and-feature-stapling

  • Do you mean in featurestapling.xml, i should include only one line like this ? <FeatureSiteTemplateAssociation Id="DA910034-F270-4932-90D0-05AE2EE13192" TemplateName="GLOBAL" /> Sorry, i am very new to SP...doing this will be sufficient? I understand everything else i am doing is correct..
    – Anonymous
    Jul 16, 2010 at 4:51
  • 1
    yea, you'll need two lines, the GLOBAL and STS#1 to staple ALL site definitions. Jul 16, 2010 at 13:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.