SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is it possible to deploy search centre via a Feature?

share|improve this question

You could use a feature event receiver to create it as a site collection or a subsite. I tend to have my search centers as site collections.

public class DefaultEventReceiver : SPFeatureReceiver {
    public override void FeatureActivated(SPFeatureReceiverProperties properties) {
        SPSecurity.RunWithElevatedPrivileges(delegate() {
            //as a site collection
            SPWebApplication app = SPWebApplication.Lookup(new Uri("http://xyz"));              
            SPSite site = app.Sites.Add("http://xyz",title,desc,1033,"SRCHCEN#0",...);
            //as a subsite
            using (SPSite site = new SPSite("http://xyz")) {
                web = site.RootWeb.Webs.Add("xyz","xyz","xyz",web.Language,"SRCHCEN#0",...);
            }           
        });
    }
}

Replace "SRCHCEN#0" with another the template name if it is different version of sharepoint.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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