Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

Is it possible to deploy search centre via a Feature?

share|improve this question

1 Answer 1

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.