对 IE 执行 Ping 操作 - 请求超时
在哪里查找“ping IP_address”返回“请求超时”的原因,但在 Internet Explorer 中打开“http://IP_address”可以正确加载站点?
实际上:.NET 对该 IP 的 WebRequest 在我的机器上可以正常工作,但在客户端上不起作用。
我认为应该有代理的东西,但不确定应该做什么。 .NET代码如下:
WebRequest request = WebRequest.Create("http://tycho.usno.navy.mil/cgi-bin/timer.pl");
WebRequest.DefaultWebProxy.Credentials = CredentialCache.DefaultCredentials;
request.CachePolicy = new HttpRequestCachePolicy(HttpRequestCacheLevel.NoCacheNoStore);
request.Proxy = WebRequest.DefaultWebProxy;
WebResponse response = request.GetResponse();
Where to look what could be a cause that "ping IP_address" returns "Request timed out", but opening "http://IP_address" in the Internet Explorer loads site correctly?
And in real impication: .NET making WebRequest to that IP works correctly on my machine, but does not work on clietn's.
I think there should be something with proxy, but not sure what should be done.
The .NET code is below:
WebRequest request = WebRequest.Create("http://tycho.usno.navy.mil/cgi-bin/timer.pl");
WebRequest.DefaultWebProxy.Credentials = CredentialCache.DefaultCredentials;
request.CachePolicy = new HttpRequestCachePolicy(HttpRequestCacheLevel.NoCacheNoStore);
request.Proxy = WebRequest.DefaultWebProxy;
WebResponse response = request.GetResponse();
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
某些服务器会阻止
ping
请求。Some servers block
ping
requests.部分服务器/防火墙/网关会拦截PING(ICMP请求),导致请求超时;加载网页时使用端口 80(大多数情况下),该端口与 ICMP 端口不同。
更新:根据您提供的信息,您提到您的代码在调试期间可以工作,但在“发布”EXE 中不起作用,对吗?默认情况下,在调试会话期间,程序会绕过大多数安全设置。
另外,请检查 Windows 防火墙设置。尝试在客户端禁用 Windows 防火墙&重试。如果 Windows 防火墙是罪魁祸首,请将您的程序添加到 Windows 防火墙“允许的程序”列表中并重新启用防火墙。
Some servers/ firewall/ gateway will block PING ( ICMP Request ), resulting in Request Timed Out; while loading a web page uses port 80 ( in most cases ), which is different than ICMP port .
UPDATE: According to your information given, you mentioned your codes WORK during debugging but does not work in a "Release" EXE, right? By default, during debugging session, the program bypasses most security settings.
Also, check Windows Firewall settings. Try disabling the Windows Firewall on client side & retry. If Windows Firewall is the culprit, add your program to Windows Firewall "Allowed Program" list and re-enable the Firewall.