Programmatically Update the Search Settings for a Site Collection

By default when we perform search our page redirect to the "/_layouts/osssearchresults.aspx".Below code explains how to programmatically update the values for the “Search Settings” which are found in the “Site Settings” of the site collection.

using (SPSite site = new SPSite("http://abhay-pc:1212/lt"))

{

    using (SPWeb web = site.OpenWeb())

   {

         web.AllProperties["SRCH_ENH_FTR_URL"] = "/SitePages/Customsearch.aspx";

         web.AllProperties["SRCH_SITE_DROPDOWN_MODE"] = "HideScopeDD_DefaultContextual" ;

         web.AllProperties["SRCH_TRAGET_RESULTS_PAGE"] = "/SitePages/Customsearch.aspx";

         web..Update();

 

      }

}