当我们的内网Web服务器需要访问外网的一个Web服务,但是我们的网络是通过代理服务器才能上网的。我们就需要告诉asp.net应用程序代理服务地址和端口。
实现方法是在Web.config的configuration配置节中增加以下配置项
Code
<system.net>
<defaultProxy>
<proxy bypassonlocal="True" proxyaddress="http://代理服务器地址:代理服务器端口" />
</defaultProxy>
</system.net>
其中几个参数说明:
<system.net>
<defaultProxy>
<proxy bypassonlocal="True" proxyaddress="http://代理服务器地址:代理服务器端口" />
</defaultProxy>
</system.net>
bypassonlocal:本地地址访问是否不使用代理服务器,true为本地地址不使用代理访问
proxyaddress:代理服务器地址和端口等信息