Please refer to the Introduction to PnP Core Component and OfficeDevPnP.Core for more details. I have created a console application and added SharePointPnPCoreOnline NuGet package for the SharePoint 2016 version.
Code Snippet
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using Microsoft.SharePoint.Client;
- using OfficeDevPnP.Core;
- namespace SP2016PnPCoreComponentDemo
- {
- class Program
- {
- static void Main(string[] args)
- {
- // Input Parameters
- string siteUrl = "http://c7395723754/";
- string userName = "administrator";
- string password = "Vk3p8L16E6";
- string domain = "AD2012";
- string leafURL = "pnpdemosite";
- string webFullURL = "http://c7395723754/pnpdemosite";
- OfficeDevPnP.Core.AuthenticationManager authMgr = new OfficeDevPnP.Core.AuthenticationManager();
- try
- {
- // Get the client context
- using (var ctx = authMgr.GetNetworkCredentialAuthenticatedContext(siteUrl, userName, password, domain))
- {
- // Check if a child web site exists with the specified leaf URL
- if (ctx.Web.WebExists(leafURL))
- {
- Console.WriteLine(leafURL + " - site exists");
- }
- // Check if a web site exists at the specified full URL
- if (ctx.WebExistsFullUrl(webFullURL))
- {
- Console.WriteLine(webFullURL + " - site exists");
- }
- }
- }
- catch (Exception ex)
- {
- Console.WriteLine("Error Message: " + ex.Message);
- }
- }
- }
- }

Join the conversation! Your thoughts help the community grow.