In C# console application , i need to capture the out "Internet cannot display the webpage", then i can put my check. If internet browser opens the url means internet connection is there, else connection down. I am using below code
    WebClient client = new WebClient();
        string value = client.DownloadString("http://foo.com");
        Console.WriteLine(value.Length);
        Console.WriteLine(value);
        Console.WriteLine("Press any key to continue");
        Console.ReadKey(true);
Please se the method to capture the output
 
     
     
    