2010-09-17 50 views
5

一個URL我的情景:問題平從C#

當我平安與www.google.com給它的地位的成功,當我嘗試ping http://stackoverflow.com我得到「ping請求期間,出現異常的異常。 「是什麼原因?我怎麼解決?

using (Ping png = new Ping()) 
{ 
    PingReply pr = png.Send("http://stackoverflow.com"); 
    string status= pr.Status.ToString(); 
} 

回答

9

不包含HTTP://,那麼它工作正常。

+4

+1 - ping與_domains_一起使用,而不是URI。 – Oded 2010-09-17 10:05:06

+1

是的,HTTP://只是告訴瀏覽器使用什麼協議,如HTTPS://或FTP:// – 2010-09-17 10:07:36

+0

Ping仍然只能用於發送的IP,而不是主機名。 [MSDN](http://msdn.microsoft.com/en-us/library/system.net.networkinformation.ping.send.aspx)說,儘管你可以使用它...任何想法呢? – JWiley 2012-12-12 15:39:42