3

I have a site collection and I want to set the search center value to be the same as another site collection. The site collection is created in code, so I need to be able to set the property after the site collection has been created.

How can I do this programatically?

Mat
  • 202,337
  • 40
  • 393
  • 406
Nat
  • 14,175
  • 5
  • 41
  • 64

1 Answers1

7

This setting is stored in the property bag of the SPWeb object. You can update it as follows:

using (SPSite site = new SPSite("http://server/site"))
using (SPWeb web = site.OpenWeb())
{
  web.AllProperties["SRCH_ENH_FTR_URL"] = "/searchcenter/pages";
  web.Update();
}
Lars Fastrup
  • 5,458
  • 4
  • 31
  • 35