TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
C# Corner
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Get All Web Count in SharePoint Online Site Collection using CSOM
Shantha Kumar T
Dec 29
2015
Code
3.2
k
0
0
facebook
twitter
linkedIn
Reddit
WhatsApp
Email
Bookmark
expand
//using Microsoft.SharePoint.Client;
//using Microsoft.Online.SharePoint.TenantAdministration;
//string weburl = "https://site.sharepoint.com";
//GetSite(credentials, weburl);
//This method returns the site collection object based on the url.
//shows the count of all subwebs available with in SharePoint online Site Collection
//Microsoft.Online.SharePoint.TenantAdministration.SiteProperties.WebsCount property
private
static
void
GetSite(SharePointOnlineCredentials credentials,
string
weburl)
{
using
(ClientContext ctx =
new
ClientContext(weburl))
{
ctx.Credentials = credentials;
Tenant tenant =
new
Tenant(ctx);
//weburl is the SharePoint Site url
//true - includes all properties of the Site Collection in the request
SiteProperties ositeProperties = tenant.GetSitePropertiesByUrl(weburl,
true
);
ctx.Load(ositeProperties);
ctx.ExecuteQuery();
Console.WriteLine(
"Total webs: "
+ ositeProperties.WebsCount);
}
Console.WriteLine(
"Press any key to exit..."
);
Console.Read();
}
SharePoint Online
SiteCollection