【问题标题】:How to set VB Application Proxy Settings to Default System Proxy Settings如何将 VB 应用程序代理设置设置为默认系统代理设置
【发布时间】:2013-06-03 13:09:08
【问题描述】:

我的应用程序应该在启用代理的公司网络上运行, 默认登录浏览器等所有应用程序后,都可以正常上网

但是当我打开我的应用程序“远程服务器返回错误 [407] 需要代理身份验证”错误来了

在普通的联网电脑上运行良好

有什么方法可以设置手动代理或者最好将系统代理设置为应用程序的默认值 我在编程领域太新手了

我的代码是

Dim PartURL As String = "http://www.google.com"
Dim request As System.Net.HttpWebRequest = System.Net.HttpWebRequest.Create(PartURL)
Dim response As System.Net.HttpWebResponse = request.GetResponse()
Dim sr As System.IO.StreamReader = New System.IO.StreamReader(response.GetResponseStream())
Dim sourcecode As String = sr.ReadToEnd()
SearchPageSource = sourcecode

我的代理设置也是

Address: abcserver04
Port:    8080

cmd 提示符下的 Ipconfig 输出是

Ethernet adapter local area connection
Connection Specific DNS Suffix : abc.defgroup.net
IP Address : 10.4.8.xx
Subnet Mask : 255.255.255.0
Default Gateway : 10.4.8.254

【问题讨论】:

  • 您收到该错误的事实表明它正在使用代理。您只需要传递正确的凭据即可。

标签: vb.net proxy ip


【解决方案1】:

试试这个...

request.Proxy.Credentials = System.Net.CredentialCache.DefaultCredentials

【讨论】:

    【解决方案2】:

    您也可以使用app.config

    来自https://stackoverflow.com/a/8180854/239408

    <system.net>
      <defaultProxy useDefaultCredentials="true" />
    </system.net>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-12-22
      • 2010-10-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-08-21
      相关资源
      最近更新 更多