I am facing this error :
The remote name could not be resolved: 'russgates85-001-site1.smarterasp.net'
When I request html contents to read using web client it gives me error. Below is my code.
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.
By default it will take system proxy.
To solve this, force to set your proxy in web.config or .cs api webclient.
Code fix should be like following, In under System.net section in web.config
<defaultProxy>
<proxy proxyaddress="http://0.000.000.000:00" bypassonlocal="True" usesystemdefault="False" autoDetect="False" />
</defaultProxy>
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With