1

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))
variable
  • 4,473
  • 13
  • 75
  • 139

1 Answers1

3

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

Arsalan Adam Khatri
  • 14,531
  • 3
  • 36
  • 59