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

This is possible:

  using (SPSite site = new SPSite(SPContext.Current.Site.WebApplication.Sites[0].Url))

Is this possible?:

 using (SPSite site = new SPSite(SPContext.Current.Site.WebApplication.Sites[0].RootWeb.Url))
share|improve this question
up vote 3 down vote accepted

Yes this will also work, but you are not putting an SPWeb object into SPSite object.. Instead you are just using the Url to instantiate a new SPSite object

In most of the cases SPSite.Url and SPSite.RootWeb.Url return same Url.. As you have already asked it here What is difference between SPSite.Url and SPSite.RootWeb.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.