6

There's a "Site Collection Search Results Page" field which is used for configuring the search results page used for contextual searches (such as "This Site"). It can be found by doing the following:

  1. Go to your SharePoint site collection
  2. Select "Site Settings" from the "Site Actions" menu
  3. Go to the "Site Collection Administration" section and select "Search Settings"
  4. The field "Site Collection Search Results Page" will be listed on the bottom.

The default value is

/_layouts/osssearchresults.aspx

How can I retrieve and change this value through the SharePoint object model?

1 Answer 1

14

The setting is stored in:

site.RootWeb.AllProperties["SRCH_TRAGET_RESULTS_PAGE"] 

If doesn't exist or is null then '/_layouts/osssearchresults.aspx' is used

The Search Center URL is in

site.RootWeb.AllProperties["SRCH_ENH_FTR_URL"] 

And the drop down mode in

site.RootWeb.AllProperties["SRCH_SITE_DROPDOWN_MODE"] 
7
  • This changes value of Site Collection Search Center (i.e. enables custom scopes). But I need to change the URL to layout itself.
    – Alexander
    Jul 22, 2010 at 9:45
  • Upps :-( gave the setting for 2007, where the page was hardcoded. Answer is now updated for 2010. Jul 22, 2010 at 10:23
  • Remember to do site.RootWeb.Update() to have the changes actually go into effect.
    – skeletank
    Mar 21, 2012 at 16:39
  • 1
    And yes, it is spelt TRAGET in the property. Jan 7, 2013 at 4:40
  • Also, be sure to wait 30 seconds to 1 minute after the Web.Update() because it seems to take a little while to take affect. If you immediately try it and the setting is not applied, you could be tempted to start changing values and you may just need to be patient. Jan 25, 2013 at 15:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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