The remote name could not be resolved: 'report.dalabs.cn'

发布时间 2023-04-01 18:54:57作者: 巴蒂青葱

1.在做程序的时候出现System.Net.WebException: The remote name could not be resolved: 'report.dalabs.cn'

百度后得到以下方法:

在webconfig文件里面添加代理配置:

<system.net>
<defaultProxy>
<proxy usesystemdefault="True" proxyaddress="http://x.x.x.x:80" bypassonlocal="True"/>
</defaultProxy>
</system.net>
我不太清楚这个方法对其他人有没有用,但是我添加了这个代码之后出现了新的报错信息

System.Net.WebException: Cannot handle redirect from HTTP/HTTPS protocols to other dissimilar ones. ---> System.UriFormatException: Invalid URI: Invalid port specified.

网上也没有查到相关的报错信息,在这个地方纠结了好久之后,返回重新排查原来的错误,System.Net.WebException: The remote name could not be resolved(远程名称无法解析)

考虑到可能是网络问题,先ping一下这个地址,果然,ping不通

 

因为考虑到目标服务器跟当前主机是在同一个局域网中,所以正常情况下不应该出现这种情况,所以问题可能出在DNS上,检查DNS,确实是DNS没有设置,设置DNS后,完美解决