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;
  • why don't you just try to make a simple "HttpWebRequest" to you site collection and check the response status returned? Sep 6, 2012 at 7:40
  • Oh! I don't know how (new to development) - could you provide an example?
    – Michael A
    Sep 6, 2012 at 9:36

1 Answer 1


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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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