1

I have a sharepoint web application, with two subsites "test1" and "test2".

enter image description here I am trying to get the subsites using classes from Microsoft.SharePoint.Client namespace.

var context = new ClientContext(string.Format("http://{0}", "www05:48042"));

context.Credentials = new NetworkCredential(credentials.Login, credentials.Password);
var sites = context.Web.Webs;
context.Load(sites);

context.ExecuteQuery();

Login and password are correct. However, I am always getting an empty collection in webs, but should get at least 2 elements. What am I doing wrong? Any suggestions?

0

Those are not subsites instead they are different site collections

Pages are what you actually see and use on SharePoint. A Site is a collection of pages. A SiteCollection is, as the name indicates, a collection of sites. A WebApplication is a collection of SiteCollections.

and AFAIK, client context does not expose objects like SPWebApplication, you can try PowerShell though:

Get-SPSite -limit all -WebApplication http://yourWebapplicationUrl | Ft -autosize -wrap | Out-File -FilePath "PathToYourFile"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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