Checking website status in .NET

.net

Solution

I always use this for checking if websites are working correctly:

public bool IsWebsiteOnline(string url)
{
    try
    {
        HttpWebRequest myReq = (HttpWebRequest)WebRequest.Create(url);
        myReq.Timeout = 10000;

        using (HttpWebResponse response = (HttpWebResponse)myReq.GetResponse()) 
        {
           return response.StatusCode == HttpStatusCode.OK;
        }
    }
    catch
    {
        return false;
    }
}

Problem

I need to build a .NET function that tests to see if a specific website is online. What is the best way to do this? I was going to simply ping the site, but I wondered if there was a more accurate method. Thanks!

Original source