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
You have to get the status code from web client.
Based on the status code you can identify the state of the current connection.
Please refer the following code.
How to get status code from webclient?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With