Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The remote name could not be resolved - webclient

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.

like image 896
k-s Avatar asked May 18 '13 16:05

k-s


2 Answers

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>
like image 189
Kamarajan Chandran Avatar answered Nov 15 '22 14:11

Kamarajan Chandran


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.

like image 21
Ken Johnson Avatar answered Nov 15 '22 16:11

Ken Johnson