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
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using Microsoft.SharePoint.Client;
  7. using OfficeDevPnP.Core;
  8. namespace SP2016PnPCoreComponentDemo
  9. {
  10. class Program
  11. {
  12. static void Main(string[] args)
  13. {
  14. // Input Parameters
  15. string siteUrl = "http://c7395723754/";
  16. string userName = "administrator";
  17. string password = "Vk3p8L16E6";
  18. string domain = "AD2012";
  19. string leafURL = "pnpdemosite";
  20. string webFullURL = "http://c7395723754/pnpdemosite";
  21. OfficeDevPnP.Core.AuthenticationManager authMgr = new OfficeDevPnP.Core.AuthenticationManager();
  22. try
  23. {
  24. // Get the client context
  25. using (var ctx = authMgr.GetNetworkCredentialAuthenticatedContext(siteUrl, userName, password, domain))
  26. {
  27. // Check if a child web site exists with the specified leaf URL
  28. if (ctx.Web.WebExists(leafURL))
  29. {
  30. Console.WriteLine(leafURL + " - site exists");
  31. }
  32. // Check if a web site exists at the specified full URL
  33. if (ctx.WebExistsFullUrl(webFullURL))
  34. {
  35. Console.WriteLine(webFullURL + " - site exists");
  36. }
  37. }
  38. }
  39. catch (Exception ex)
  40. {
  41. Console.WriteLine("Error Message: " + ex.Message);
  42. }
  43. }
  44. }
  45. }