Question

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))
Was it helpful?

Solution

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

Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top