SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am looking for a "cheap" option to find out if a site exists, given a URL.

I have no control over the server environment, so I am not able to add web services or code to it.

Is there a way to find out whether a site exists on the specified URL without resorting to catching ClientRequestException?

share|improve this question

So I know this is old, but Community decided we should look at it today...

You can enumerate the subwebs and put all the urls as keys in an object, then check if the url was put into the object or not...

var myCtx = SP.ClientContext.get_current();
var mySubWebs = myCtx.get_web().getSubwebsForCurrentUser();

myCtx.executeQueryAsync(function() {
    var subWebEnum = mySubWebs.getEnumerator(),
        webUrls = {},
    while (subWebEnum.moveNext()) {
        currWeb = subWebEnum.get_current();
        webUrls[currWeb.get_url()] = true;
    //following line for debugging in console
    window.subWebs = webUrls;
}, function(sender, args) {
    //failure handler

Then you can do things like subWebs['<absolute url>'] ? present : notPresent or if(subWebs['<absolute url>']) and make decisions based on that.

You do need to be on a page in the web where you are looking for subwebs in order for this to work.

share|improve this answer

I know these are not client object model related, but wouldn't these be quicker?

  1. Try pinging it? (if you get a response, there a good chance it exists).
  2. Use a http tool such as fiddler
share|improve this answer
I am looking for answers involving code... I know I can use WebRequest and see if I get a 404, but really interested in a "proper" SharePoint way of doing this. – Oded Jun 11 '12 at 13:46

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.