SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I thought it would limit where you search, but when I tried to do something like this:

fullTextSqlQuery.SiteContext = new Uri("");

It returned results from other sites besides mySite. I've seen MSDN's nearly useless explanation of:

Gets or sets the site URL for the search query.

What does this mean? What am I actually setting when I specify a SiteContext?

share|improve this question
up vote 0 down vote accepted

It appears that mySite is a subweb of a site collection. The SiteContext refers to the site collection, not a web (site), which may be why you are seeing results outside of your web site mySite.

So if you have a site collection at, and you specify as SiteContext, it will still use the site collection base Url

share|improve this answer
I believe that mySite is a site collection as well as the base site. Could this be confusing SharePoint? – Abe Miessler Dec 22 '11 at 1:33
No, if mySite is a site collection, then the SiteContext should set the context of the query to your site collection only. – Russell Dec 22 '11 at 1:36

The SiteContext property is not related to the scope of the query. It just specifies the alternate access mapping zone for the result urls. Otherwise, the results will always return urls for the default zone. You can set it as follows:

fullTextSqlQuery.SiteContext = new Uri(SPContext.Current.Site.Url);
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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