6

I want to create and deploy a web part as web-scoped feature.

In Visual Studio 2010, when I make the feature scope=web, I cannot add the webpart to that feature as I am able to do when scope=site.

3
  • What is the error you are getting? And what are you doing when you get the error.
    – Laurie
    Jun 14, 2011 at 4:45
  • i am not getting any error. In visual studio 2010,i am creating webpart then i am creating new feature : scope =web When i set the scope of feature as web , i am not able to deploy my webpart . This we could do in MOSS 2007 . Jun 14, 2011 at 4:59
  • If you do not get an error, what do you mean by "not able to deploy my webpart"? Do you add & deploy the wsp and the feature does not show up in Site Actions > Site Settings > Manage site features?
    – Laurie
    Jun 14, 2011 at 5:11

1 Answer 1

16

You can't deploy a Web Part at the Scope = Web level. Web Parts must be deployed at the Site level since the .dwp or .webpart file needs to be deployed to the Web Part gallery, which is at the Site Collection level.

4
  • 2
    Good point. Although, I believe technically you can create a web-scoped feature and set it as RootWebOnly="TRUE". It could only be activated at the root site where the web part gallery resides. But that wouldn't really achieve anything, since it would be usable by all subsites. It makes the most sense to just make it site-scoped.
    – Laurie
    Jun 14, 2011 at 6:18
  • The VS2010 Feature Designer is built to filter out elements that are appropriate to various scopes. Web Parts are filtered to the Site scope, so despite the fact that it is technically possible, you would have to hand-tool the Feature.XML to be able to do it. Content Types and Site Columns are better examples of an element that the Feature Designer allows to be scoped to either Site or Web, since it is practical that you may wish to deploy these for an entire site collection, or only at a specific sub-site. Jun 14, 2011 at 15:25
  • I would like to know where does the webpart get stored when we deploy it via wsp? Is it in the LAYOUTS folder or content db?\
    – variable
    Apr 8, 2014 at 6:35
  • The web part gallery is just like any other list in a Site Collection and is stored in the content database containing the site collection. Apr 11, 2014 at 15:23

Your Answer

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

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