Check to see if site is online, limit the timeout
<p>I'm trying to make a function that checks if a site is online or not, but is having some problem with the timeout. I want to limit it to a max 3 sec, if there is no respons within 3 sec I should see the page as offline. </p>

<p>My try:</p>

<pre><code>class OnlineCheck
    {
        public static bool IsOnline(string url)
        {
            try
            {
                WebClient webclient = new WebClient();
                webclient.Headers.Add(HttpRequestHeader.KeepAlive, "1000");

                webclient.OpenRead(url);
            }
            catch { return false; }

            return true;
        }
    }
</code></pre>
