博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
使用WebClient 或者 HttpWebRequest均报:"The Remote name can't be solved"
阅读量:7064 次
发布时间:2019-06-28

本文共 1836 字,大约阅读时间需要 6 分钟。

错误原因: 未配置代理服务器设置的问题, 需要在配置节做如下操作.

 

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

 

 

 

文章编号: 318140 - 查看本文应用于的产品
机器翻译查看机器翻译免责声明
逐句中英文参照视图Microsoft 支持页面的机器翻译
展开全部 | 关闭全部
Collapse image本文内容
Collapse image症状
注意:这篇文章中引用了以下.NET Framework 类库命名空间:

System.Net

当您使用.NET 客户端使用的 HTTP 代理服务器的 Web 服务时,您可能会收到以下错误消息:

基础连接已关闭: 无法解析此远程名称。
回到顶端回到顶端 | 提供反馈
Collapse image原因
HTTP 代理服务器的 Web 服务,.NET 客户端之间不存在和尚未配置正确的代理服务器设置。
回到顶端回到顶端 | 提供反馈
Collapse image解决方案
要解决此问题,请提供正确的代理向.NET 客户端配置设置。
回到顶端回到顶端 | 提供反馈
Collapse image更多信息
Machine.config 文件中的默认设置如下:

<configuration>

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

默认设置不会自动检测代理服务器设置,如果将usessystemdefault设置为 false,然后显式指定的代理服务器。若要显式指定代理服务器,使用的 Machine.config 或 Web.config 文件,或以编程方式指定的服务器。

若要指定代理服务器,设置的 Machine.config 或 Web.config 文件设置,如下所述:

<configuration>

<system.net>
<defaultProxy>
<proxy
usesystemdefault = "false"
proxyaddress="http://proxyserver"
bypassonlocal="true"
/>
</defaultProxy>
</system.net>
</configuration>

若要使用web 代理对象以编程方式更改设置,请使用下面的代码示例:

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();

 

要求 NTLM 身份验证的代理服务器

若要设置 NTML 身份验证的代理服务器,请使用下面的代码示例:

Using System.Net;

WebProxy myProxy = new WebProxy("http://proxyserver:port",true);

myProxy.Credentials = CredentialCache.DefaultCredentials;
FindServiceSoap myFindService = new FindServiceSoap();
myFindService.Proxy = myProxy;
您还可以使用系统范围的代理为默认值。
<configuration>
<system.net>
<defaultProxy>
<proxy
proxyaddress = "http://proxyserver:80"
bypassonlocal = "true" />
</defaultProxy>
</system.net>
</configuration>
回到顶端回到顶端 | 提供反馈

转载于:https://www.cnblogs.com/cs_net/p/4324317.html

你可能感兴趣的文章
rhce第二天笔记
查看>>
oneproxy中间件架构及注意事项
查看>>
phpweb解析不当加上传漏洞
查看>>
CentOS自动挂载NTFS分区的U盘或者移动硬盘
查看>>
2018-2019-1 20165226 20165310 20165315 实验二 固件程序设计
查看>>
安装windows后grub的恢复
查看>>
android学习总结(20120721)
查看>>
安装rrdtool时候的报错configure: error: Please fix the library issues listed above and try again....
查看>>
创建一个10G可用空间的RAID5
查看>>
snmp安装
查看>>
elasticsearch常用操作命令
查看>>
设置sqlplus提示符
查看>>
存储类说明符
查看>>
MySQL 简易序列
查看>>
nginx keepalive
查看>>
Markdown 语法说明
查看>>
CentOS 7.0安装配置LAMP服务器(Apache+PHP+MariaDB)
查看>>
Django 跨表查询--神奇的双下划线和点
查看>>
h3cte D图 搭建
查看>>
Linux 文件基本属性
查看>>