Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Problem ping a URL from C#

Tags:

c#

exception

ping

My scenario:

When i ping with www.google.com it give the status Success, When i try to ping http://stackoverflow.com i got an exception "An exception occurred during a Ping request." What is the reason? how can i solve?

using (Ping png = new Ping())
{
  PingReply pr = png.Send("http://stackoverflow.com");
  string status= pr.Status.ToString();
}
like image 879
anbuselvan Avatar asked Sep 17 '10 10:09

anbuselvan


People also ask

How do I ping a URL from the command line?

Hold down the Windows key and the R key at the same time to open the Run Prompt window, type "cmd" into the bar, then click OK or press Enter. In the Command Prompt window, type "ping" followed by the destination — either an IP address or a domain name, then press Enter.

What is C in ping?

-c. Specifies the number of packets. This option is useful when you get an IP trace log. You can capture a minimum of ping packets.

Why would a ping command not work?

It means that your ICMP packet (ping) was silently discarded with no response sent. That might happen for several reasons: Ping is disabled on router or (more likely) end point. Network is congested or misconfigured.

Why is my website not pinging?

(In case you have heard the term HTTP, it is a protocol which is one layer up from ICMP or TCP.) What this means is that any router or firewall between you and the server you try to ping may just block your pings. Pinging a server is not a reliable way to see if it is up.


1 Answers

Don't include the HTTP://, then it works fine.

like image 200
Joachim VR Avatar answered Sep 30 '22 19:09

Joachim VR