Answered by:
Not able to download the content file - Getting Error: The proxy name could not be resolved: 'http'

Question
-
User-1024101449 posted
I am trying to download the content file from specific URL. But, i'm getting error.
below is my code :
DownloadURL = "http://servertest.mnet.comp.intranet:80/tm-rest/repos/contents/content"; // To get content from URL WebClient client = new WebClient(); WebProxy wp = new WebProxy("http://servertest.mnet.comp.intranet",80); wp.Credentials = new NetworkCredential("test1", "pass", "mnet.comp.intranet"); client.Proxy = wp; client.DownloadFile(DownloadURL, "c:\\Content\\content.txt");
Error : The proxy name could not be resolved: 'http'
What is the error and how we could solve this problem...?
Wednesday, May 29, 2019 1:57 PM
Answers
-
User-893317190 posted
Hi gani7787,
From your code , your proxy and target address it the same.
Although you provides username and password when using the proxy, when the proxy forwards your request to the target address , it may not provide username and password.
So, if your computer could directly connects to the server and provide username and password, you could include the username and password directly in the webclient when sending request instead of using a proxy.
For how to provide username and password using webclient , you could refer to https://www.hashemian.com/blog/2007/06/http-authorization-and-net-webrequest-webclient-classes.htm
Also , refer to https://stackoverflow.com/questions/16044313/webclient-httpwebrequest-with-basic-authentication-returns-404-not-found-for-v for more way to include username and password.
Best regards,
Ackerly Xu
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Thursday, May 30, 2019 9:57 AM
All replies
-
User475983607 posted
The proxy server does not exist or DNS is not configured.
https://docs.microsoft.com/en-us/dotnet/api/system.net.webproxy?view=netframework-4.8
Wednesday, May 29, 2019 2:06 PM -
User-893317190 posted
Hi gani7787,
You could try to pin http://servertest.mnet.comp.intranet to see whether your computer has network connection to http://servertest.mnet.comp.intranet.
If you have http://servertest.mnet.comp.intranet's ip address , try to directly input the ip address of your http proxy to see what happens.
Please ensure you have internet connection to your proxy.
Best regards,
Ackerly Xu
Thursday, May 30, 2019 3:12 AM -
User-1024101449 posted
my computer has already in network. pinging the domain ip and it's working.
when i directly open the url through browser, it will be asking usename and password. when i give user name and password then it will open the content file.
But, same when i execute trough code with correct credentials, again it shows "The remote server returned an error: (401) Unauthorized." (don't know why it is...????)
Is it possible to read content tag without downloading URL file,
Thursday, May 30, 2019 5:35 AM -
User-893317190 posted
Hi gani7787,
From your code , your proxy and target address it the same.
Although you provides username and password when using the proxy, when the proxy forwards your request to the target address , it may not provide username and password.
So, if your computer could directly connects to the server and provide username and password, you could include the username and password directly in the webclient when sending request instead of using a proxy.
For how to provide username and password using webclient , you could refer to https://www.hashemian.com/blog/2007/06/http-authorization-and-net-webrequest-webclient-classes.htm
Also , refer to https://stackoverflow.com/questions/16044313/webclient-httpwebrequest-with-basic-authentication-returns-404-not-found-for-v for more way to include username and password.
Best regards,
Ackerly Xu
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Thursday, May 30, 2019 9:57 AM