Skip to content

Instantly share code, notes, and snippets.

@sksnips
Created June 16, 2016 05:37
Show Gist options
  • Save sksnips/4f6f9bb4bc454b80ffa59608d6614692 to your computer and use it in GitHub Desktop.
Save sksnips/4f6f9bb4bc454b80ffa59608d6614692 to your computer and use it in GitHub Desktop.
This example returns the child Web site with the specified leaf URL.
//Author: Shantha Kumar T
//Assembly Reference Used: OfficeDevPnP.Core, Version=2.5.1606.1, Culture=neutral, PublicKeyToken=3751622786b357c2
//Supports: SharePoint Online, SharePoint 2013+
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.SharePoint.Client;
using OfficeDevPnP.Core;
// Assembly Reference Used: OfficeDevPnP.Core, Version=2.5.1606.1, Culture=neutral, PublicKeyToken=3751622786b357c2
namespace PnPSitesCore.Samples
{
class Program
{
static void Main(string[] args)
{
string siteUrl = "https://sharepointonline.sharepoint.com";
AuthenticationManager authManager = new AuthenticationManager();
//Interactive Login to SharePoint site - Opens a Online signin page to authenticate the user
var context = authManager.GetWebLoginClientContext(siteUrl);
//Returns the server-relative url of the instantiated web object
Web oweb = context.Web.GetWeb("subsite");
Console.WriteLine(oweb.ServerRelativeUrl);
Console.WriteLine("Press any key to exit.");
Console.ReadKey();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment