title: Check to see if a SharePoint site exists or not
body: <p>This is my code which checks if a SharePoint site exists or not.</p>
  
  <pre><code>string URL = Console.ReadLine();
  using (SPSite objSite = new SPSite(URL))
  {
      using (SPWeb objWeb = objSite.OpenWeb())
      {
        Console.WriteLine(string.Format("Site Exists: {0}", objWeb.Exists.ToString()));
      }
  }
  </code></pre>
  
  <p>However, it doesn't seem to work. The "Exists" property always returns true even if the site/subsite does not exists. I get the same result when the URL is either "<a href="http://intranet" rel="nofollow noreferrer">http://intranet</a>"  or "<a href="http://intranet/sitedoesnotexists" rel="nofollow noreferrer">http://intranet/sitedoesnotexists</a>".</p>
  
  <p>Am I using this in the correct way?</p>
  
  <p>Thanks</p>
  
  <p><strong>Edit</strong></p>
  
  <p>Sorry about the formatting, I was sure that I applied it but I guess I forgot.</p>