I have an arbitrary url. I know this url represents some path on my local SharePoint server. With the SharePoint API, I want to know if there is a site corresponding to this url. What's the best way to do this?
I thought this should work:
using (SPSite site = new SPSite(url))
{
using (SPWeb web = site.OpenWeb())
{
bool exists = web.Exists;
}
}
But this seems to return true even when the SPWeb isn't really there. For example, if I have an actual site at this url:
http://myserver/a/b
Then the above code returns true if I ask for this site, even when it's not really a provisioned site:
http://myserver/a/b/c
In this case, the reference to "web" is actually the http://myserver/a/b web site, which is not really what I wanted. What's the right way to check to see if this site is really there?