Using WebClient or HttpWebRequest: "The Remote name can ' t be solved"

Source: Internet
Author: User

Cause of error: No proxy server settings are configured, you need to do the following in the configuration section.

============================================


Article ID: 318140-View products that this article applies to.
Machine translation View machine translation Disclaimer
Step through the English Reference View machine translation for Microsoft support pages
Expand All | Close all
Collapse image This article
Collapse Image Symptoms
Note: The following. NET Framework class library namespaces are referenced in this article:

System.Net

When you use a WEB service that uses the HTTP proxy server for a. NET client, you may receive the following error message:
The underlying connection was closed: The remote name could not be resolved.
Back to Top | Provide feedback
Collapse image Reason
The HTTP Proxy Server Web service does not exist between. NET clients and the correct proxy settings have not been configured.
Back to Top | Provide feedback
Collapse Image Solution
To resolve this issue, provide the correct proxy configuration settings to the. NET client.
Back to Top | Provide feedback
Collapse image for more information
The default settings in the Machine.config file are as follows:

<configuration>
<system.net>
<defaultProxy>
<proxy
Usesystemdefault = "true"
/>
</defaultProxy>
</system.net>
</configuration>


The default setting does not automatically detect proxy settings if you set Usessystemdefault to False and then explicitly specify the proxy server. To explicitly specify a proxy server, use the Machine.config or Web. config file, or specify the server programmatically.

To specify a proxy server, set the Machine.config or Web. config file settings as follows:

<configuration>
<system.net>
<defaultProxy>
<proxy
Usesystemdefault = "false"
Proxyaddress= "Http://proxyserver"
Bypassonlocal= "true"
/>
</defaultProxy>
</system.net>
</configuration>


To programmatically change settings by using a Web proxy object, use the following code example:

Using System.Net;

Com.someserver.somewebservice.someclass MyWebServiceClass = new Com.someserver.somewebservice.someclass ();

IWebProxy proxyobject = new WebProxy ("http://myproxyserver:80", true);
Mywebserviceclass.proxy = Proxyobject;

Mywebserviceclass.mywebmethod ();


Proxy servers that require NTLM authentication

To set up a proxy server for NTML authentication, use the following code example:
Using System.Net;

WebProxy myproxy = new WebProxy ("Http://proxyserver:port", true);
Myproxy.credentials = CredentialCache.DefaultCredentials;
Findservicesoap myfindservice = new Findservicesoap ();
Myfindservice.proxy = myproxy;
You can also use system-wide proxies as default values.
<configuration>
<system.net>
<defaultProxy>
<proxy
proxyaddress = "http://proxyserver:80"
bypassonlocal = "true"/>
</defaultProxy>
</system.net>
</configuration>
Back to Top | Provide feedback

Using WebClient or HttpWebRequest: "The Remote name can ' t be solved"

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.