我面临这个错误:
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");
当我在本地代码/环境中放置相同的 URL 时,它可以正常工作。