SearchContext.GetContext method (SPSite)

NOTE: This API is now obsolete.

Gets the search context instance for the specified SPSite object.

Namespace:  Microsoft.Office.Server.Search.Administration
Assembly:  Microsoft.Office.Server.Search (in Microsoft.Office.Server.Search.dll)

<ObsoleteAttribute("This class is obsolete now. Please use SearchServiceApplication and SearchServiceApplicationProxy instead.")> _
Public Shared Function GetContext ( _
	site As SPSite _
) As SearchContext
Dim site As SPSite
Dim returnValue As SearchContext

returnValue = SearchContext.GetContext(site)


Type: Microsoft.SharePoint.SPSite

If you specify an SPSite object in the GetContext method to retrieve the search context, we recommend that your code instantiates the SPSite object within a using statement to ensure the object is released once it's no longer needed. See code in the Example section.

For more information about the SearchContext class and the SharePoint Enterprise Search Administration object model, see Getting Started with the Search Administration Object Model and How to: Return the Search Context for the Search Service Provider.


SearchContext context;
using (SPSite site = new SPSite("http://yourSiteName"))
     context = SearchContext.GetContext(site);