gpt4 book ai didi

c# - IE能浏览网址但ping不通

转载 作者:太空宇宙 更新时间:2023-11-03 20:39:53 24 4
gpt4 key购买 nike

public static string GetAccessErrorString(string uri)
{
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uri);

try
{
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
}
catch (Exception e)
{
return e.Message;
}

return null;
}

我只是想检查上面代码中网站的可访问性。调用 GetResponse 方法时出现以下错误。

at System.Net.HttpWebRequest.GetResponse() at WebStuff.WebsiteReachable.GetAccessErrorString(String uri, WebProxy proxy) in WebsiteReachable.cs:line 22

Error : The remote name could not be resolved: 'www.microsoft.com'

我在主机文件中添加了这个并尝试过但它也没有用。

实际上我可以在 IE 中浏览该站点。当我给 ping www.microsoft.com 时,我收到以下消息

*Ping request could not find host microsoft.com. Please check the name and try again. *

你能帮我解决这个问题吗?..如果你能指出不同的可能性,那就太好了。

最佳答案

您可能在 proxy server 后面运行此代码这需要身份验证,并且 Internet Explorer 配置为使用此代理,而您的代码则不需要。

关于c# - IE能浏览网址但ping不通,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3460043/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com