SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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 was wondering how people have gone about programatically checking if SharePoint is still available?

I use the following now to check it, but it relies on the SharePoint object model and must run on the machine in question... is there an approach for doing this remotely? Simply pinging the server is not an option as this won't pick up on instances when IIS has stopped working:

public class Uptime
        /// <summary>
        /// Checks uptime directly by using the SharePoint Object Model
        /// </summary>
        /// <param name="siteCollection">The site collection to check availability for</param>
        /// <returns>True on a connection, false if no connection was able to be made</returns>
        public bool CheckUptimeDirect(string siteCollection)
                using (var site = new SPSite(siteCollection))
                    using (var web = site.OpenWeb())
                        return true;
            catch (Exception)
                return false;
share|improve this question
why don't you just try to make a simple "HttpWebRequest" to you site collection and check the response status returned? – Furqan Sep 6 '12 at 7:40
Oh! I don't know how (new to development) - could you provide an example? – Codingo Sep 6 '12 at 9:36
up vote 3 down vote accepted

you can try the following ,

       string siteColl = @"http://server:port/" ;
       HttpWebRequest hwr = HttpWebRequest.Create(siteColl) as HttpWebRequest;
        //hwr.Credentials = new System.Net.NetworkCredential("user","pass","domain") ;
        HttpWebResponse resp =  hwr.GetResponse() as HttpWebResponse;
        if (resp.StatusCode == HttpStatusCode.OK)
            Response.Write("site is up and running.");

if the site has anonymous access enabled and is up and running, you shall know of it. You can also pass network credentials if it allows authenticated users only. And this should work remotely as well, without any sharepoint API.

share|improve this answer

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.