Quantcast
Channel: Is there a faster way to check if an external web page exists? - Stack Overflow
Viewing all articles
Browse latest Browse all 6

Is there a faster way to check if an external web page exists?

$
0
0

I wrote this method to check if a page exists or not:

protected bool PageExists(string url){try    {        Uri u = new Uri(url);        WebRequest w = WebRequest.Create(u);            w.Method = WebRequestMethods.Http.Head;        using (StreamReader s = new StreamReader(w.GetResponse().GetResponseStream()))        {            return (s.ReadToEnd().Length >= 0);        }    }        catch    {        return false;        }    }

I am using it to check a set of pages (iterates from AAAA-AAAZ), and it takes between 3 and 7 seconds to run the entire loop. Is there a faster or more efficient way to do this?


Viewing all articles
Browse latest Browse all 6

Latest Images

Trending Articles



Latest Images