kbrimington
kbrimington

Reputation: 25652

How do I Get SharePoint 2010 WebApplication-scoped features to Activate Only on One Web Application

I am developing a solution for SharePoint 2010 SP1. My solution provides several timer jobs, which are instantiated using a feature and a feature receiver.

The feature is scoped to a WebApplication, which seemed natural since the timer jobs are associated with the same web application. The solution is also a full-trust solution.

The solution deploys to a specific web application (http://portal.xyz.net), and only to that web application; however, it appears that the feature gets activated on all web applications within the farm, except Central Administration. As a result, the timer job gets created on all web applications.

This causes failures in some cases, and redundant code execution in others. What I really want is for the feature to activate only on the web application to which I deploy the solution.

Any ideas on how I can configure this properly?

Update 1

We have tried deploying the solution three ways, all with the same behavior:

After the deploy step in any case, we see the solution deployed to the single web application, but the WebApplication-scoped features are activated on all web applications except central admin. The behavior we want is to activate these features only on the application that we deploy to.

Upvotes: 2

Views: 4846

Answers (3)

Kerry Williams
Kerry Williams

Reputation: 21

If you want to prevent the timer job from activating on all of the web applications you just need to set the Feature property called "Activate On Default" to False. When you deploy the feature to a web application the feature will not activate so you just need to activate it through Central Admin or a PowerShell script. You can modify the Feature property in Visual Studio by opening the Feature Designer, selecting the feature on the left and it's the first property in the Property window.

Upvotes: 2

Dinesh
Dinesh

Reputation: 11

  1. Go to the Feature and Give F4
  2. In the Properties window, Select False in Activate on Default Property.
  3. Then deploy the solution.

Upvotes: 1

Thorsten Hans
Thorsten Hans

Reputation: 2683

did you use PowerShell to deploy you WSP or are you deploying from within Visual Studio. By using the PowerShell commandlets for SharePoint you could easily configure where the features will be deployed to.

Add-PSSnapIn Microsoft.SharePoint.Powershell
Add-SPSolution -LiteralPath C:\install\MyWSP.wsp
Deploy-SPSolution -Identity MyWSP.wsp -GACDeployment -WebApplication http://mysite

While Deploying WSPs manually from CA you're also able to select the WebApplication your features will be deployed to.

By default your features are deployed to all WebApps in your Farm

Upvotes: 0

Related Questions