I am facing this error :
我正面临这个错误:
The remote name could not be resolved: 'russgates85-001-site1.smarterasp.net'
无法解析远程名称:'russgates85-001-site1.smarterasp.net'
When I request html contents to read using web client it gives me error. Below is my code.
当我请求使用Web客户端读取html内容时,它给了我错误。以下是我的代码。
string strHTML = string.Empty;
WebClient myClient = new WebClient();
UTF8Encoding utf8 = new UTF8Encoding();
byte[] requestHTML;
string pdfFileName = "outputpdf_" + DateTime.Now.Ticks + ".pdf";
string webUrl = Request.Url.Scheme + "://" + Request.Url.Host + (Request.Url.Port != 80 ? ":" + Request.Url.Port : "");
requestHTML = myClient.DownloadData("http://russgates85-001-site1.smarterasp.net/adminsec/images/printinvoice.aspx?iid=2");
// OR
requestHTML = myClient.DownloadData(webUrl + "?iid=3");
When I put the same URL on my local code/environment it works fine.
当我在我的本地代码/环境中放置相同的URL时,它工作正常。
3 个解决方案
#1
6
Most likely the other location you run the code on indeed does not have access to that remote location. I.e. in many corporate environment servers aren't allowed outside Internet access. You may want to try to ping/traceroute russgates85-001-site1.smarterasp.net
from that other server and if there's no access - configure router/firewall (open port etc.) or use proxy
很可能您运行代码的其他位置确实无法访问该远程位置。即在许多企业环境服务器中不允许外部Internet访问。你可能想尝试从其他服务器ping / traceroute russgates85-001-site1.smarterasp.net,如果没有访问权限 - 配置路由器/防火墙(开放端口等)或使用代理
#2
5
I ran into this and needed to use the IP of the remote server rather than the DNS name. Production was trying to access the remote server using its DNS name, which was not viable on that side of the firewall.
我碰到了这个并且需要使用远程服务器的IP而不是DNS名称。生产试图使用其DNS名称访问远程服务器,这在防火墙的那一侧是不可行的。
#3
1
I had the same issue and got it resolved by setting the Proxy for the webclient
我遇到了同样的问题,并通过为webclient设置代理来解决它
explicitly like
webClient.Proxy = new WebProxy("myproxy.com:portnumber");
byte[] bytearr= webClient.DownloadData(acsMetadataEndpointUrlWithRealm);
#1
6
Most likely the other location you run the code on indeed does not have access to that remote location. I.e. in many corporate environment servers aren't allowed outside Internet access. You may want to try to ping/traceroute russgates85-001-site1.smarterasp.net
from that other server and if there's no access - configure router/firewall (open port etc.) or use proxy
很可能您运行代码的其他位置确实无法访问该远程位置。即在许多企业环境服务器中不允许外部Internet访问。你可能想尝试从其他服务器ping / traceroute russgates85-001-site1.smarterasp.net,如果没有访问权限 - 配置路由器/防火墙(开放端口等)或使用代理
#2
5
I ran into this and needed to use the IP of the remote server rather than the DNS name. Production was trying to access the remote server using its DNS name, which was not viable on that side of the firewall.
我碰到了这个并且需要使用远程服务器的IP而不是DNS名称。生产试图使用其DNS名称访问远程服务器,这在防火墙的那一侧是不可行的。
#3
1
I had the same issue and got it resolved by setting the Proxy for the webclient
我遇到了同样的问题,并通过为webclient设置代理来解决它
explicitly like
webClient.Proxy = new WebProxy("myproxy.com:portnumber");
byte[] bytearr= webClient.DownloadData(acsMetadataEndpointUrlWithRealm);