When using Office SharePoint Server 2007 or Search Server 2008 you can configure the used Search Center in the Search Settings of the Site Collection. When you need to know the configured value in your own code, you have to read the element with the key SRCH_ENH_FTR_URL from the AllProperties-collection of the root web of the site collection.

Here is some sample code:

static string GetConfiguredSearchCenter(SPSite site)
{
    const string SEARCH_CENTER_PROPERTY_KEY = “SRCH_ENH_FTR_URL”;
    string strResult = String.Empty;     using (SPWeb web = site.RootWeb)
    {
        if (web.AllProperties.ContainsKey(SEARCH_CENTER_PROPERTY_KEY) == true)
        {
            strResult = web.AllProperties[SEARCH_CENTER_PROPERTY_KEY] as string;
        }
    }
    return strResult;
}

Advertisements