We have an web-level feature that when you activate it will change the master pages used by the web to point to a .master page in the rootweb of the site collection.

This feature has been activated on a particular web, and worked (i.e. our new master page is in use). The web was then saved as a Site Template. When a new web was created using that template, the new web does not use our custom master page. Instead, it uses v4.master.

This is surprising - I thought that saving the template would persist the URL to our custom master page.

Also, the feature is showing as being Activated for the new web. However, attaching to the process in Visual Studio, the FeatureActivated method is not called during site creation. If I manually deactivate and reactivate the feature, my breakpoints in Visual Studio are hit.

I did download the site template and unzip it to check inside. In the ONET.xml file I can see my feature listed as a Feature under WebFeatures.


  • My Master Page URLs aren't persisted in the Site Template. Is this because they are from outside the site itself?
  • The Site Template does seem to know about my web level feature...
  • ...and shows it as active, but the FeatureActivated code doesn't appear to be run at site creation.
  • Running the code manually does show in Visual Studio, and works.

Any ideas what I've done wrong or not understood? Or is this a bug? We'd prefer our customer to be able to build their own site templates, so I'd prefer not to resort to feature stapling, and I can't understand why I'd have to.

1 Answer 1


Investigation shows that the features that have been activated when a template is saved are not re-activated when the template is used to provision a site.

I also suspect that the 'Save Site as template' process detects that the master page being used is outsite the site itself, and resets to using the V4.master. If I put a copy of my master page within the template site, use that for the site's master page, and then save the site as a template then a newly instantiated site works correctly - using a copy of my master page.

This is a little unfortunate - it does mean we can't have one centralised master page that's used everywhere in the Site Collection - but it'll do as a solution for now.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.