Sunday, January 11, 2009

Activating feature on Central Administration Web Application

In today's class , I was explaining about how to create a new feature receiver and some one asked me an interesting question about how to activate a feature on Central Administration Web Application.

Solution :
I start digging it and found something really interesting. Feature schema exposes a property name AutoActivateInCentralAdmin. Once set it to TRUE , it will be activated on Central Administration.

Now before you really start jumping , keep in mind that this will not restrict the feature to show up in other Web Application in which it was deployed and can be activated or deactivated. So if you really wanted a feature to be effective for only Central Administration then you need to check in Feature Activation event.

<?xml version="1.0" encoding="utf-8"?>
<Feature Id="GUID" Title="ContentType1" Scope="Site" Version="" Hidden="FALSE" DefaultResourceFile="core" AutoActivateInCentralAdmin="TRUE"> xmlns=""
<ElementManifest Location="ContentTypeX\ContentTypeX.xml" />

As per MSDN : TRUE if the Feature is activated by default in the Administrative Web site, site collection, or Web application. This attribute equals FALSE by default. The AutoActivateInCentralAdmin attribute does not apply to Farm-scoped Features.