k-s*_*k-s 9 c# asp.net webclient
我正面临这个错误:
The remote name could not be resolved: 'russgates85-001-site1.smarterasp.net'
当我请求使用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");
Run Code Online (Sandbox Code Playgroud)
当我在我的本地代码/环境中放置相同的URL时,它工作正常.
很可能您运行代码的其他位置确实无法访问该远程位置.即在许多企业环境服务器中不允许外部Internet访问.你可能想尝试russgates85-001-site1.smarterasp.net 从其他服务器ping/traceroute ,如果没有访问权限 - 配置路由器/防火墙(开放端口等)或使用代理
| 归档时间: |
|
| 查看次数: |
49321 次 |
| 最近记录: |