Click to Rate and Give Feedback
MSDN
MSDN Library
Web Development
SDK Documentation
SPWeb Class
SPWeb Properties
 Features Property
Community Content
In this section
Statistics Annotations (3)
Collapse All/Expand All Collapse All
This page is specific to
The 2007 product release

Other versions are also available for the following:
SPWeb.Features Property (Microsoft.SharePoint)
Gets the collection of Features that are currently activated in the Web site.

Namespace: Microsoft.SharePoint
Assembly: Microsoft.SharePoint (in microsoft.sharepoint.dll)
Visual Basic (Declaration)
Public ReadOnly Property Features As SPFeatureCollection
Visual Basic (Usage)
Dim instance As SPWeb
Dim value As SPFeatureCollection

value = instance.Features
C#
public SPFeatureCollection Features { get; }

Property Value

An SPFeatureCollection object that represents the Features.
Community Content   What is Community Content?
Add new content RSS  Annotations
Gets the collection of features currently available on the Web / Site "that are activated"      Bruce VB1   |   Edit   |   Show History

Documentation is incorrect or this is bug in WSS 3.0 SP0 that may be corrected in a later HF or SP. MS please let us know which.

Feature.Collection only returns features that are activated. You need to use SPFarm.Local.FeatureDefinitions to return which are available and programically determine which ones are installed and not active.

                foreach (SPFeatureDefinition SpFeat in SPFarm.Local.FeatureDefinitions)
{
if (SpFeat.Scope == SPFeatureScope.Site)
		.....

Re: Gets the collection of features currently available on the Web / Site "that are activated"      -Rob-   |   Edit   |   Show History

Documentation seems incorrect. The Documentation of SPFeatureCollection Class states the following:

Use the Features property of the Microsoft.SharePoint.Administration.SPWebApplication, Microsoft.SharePoint.Administration.SPWebService, SPSite, or SPWeb class to get the collection of Features that are activated in the Web application, Web service, site collection, or site.

Tags What's this?: Add a tag
Flag as ContentBug
As Designed      Ranbou   |   Edit   |   Show History
This seem to be the way it was designed. I support this by pointing to the fact the SPFeatureCollection has Add and Remove methods but does not have Activate/Enable or Deactivate/Disable methods. Also, the documentation for SPFeatureCollection.Add seems to clarify. Here is an excerpt (I added the bold font to draw attention to the pertinent information):

SPFeatureCollection.Add Method (Guid) (Microsoft.SharePoint)

Adds the Feature with the specified GUID to the collection of activated Features for the Web application, Web service, site collection, or Web site.
Tags What's this?: Add a tag
Flag as ContentBug
Processing
© 2010 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks | Privacy Statement
Page view tracker