vb.net代理服务器

问题描述:

我们的服务器具有代理,要使用Internet,我们应该输入用户名和密码才能使用Internet.

如何编写程序以通过vb.net中的代理服务器?

我的代码有什么问题??
错误407 !!!
:(

our server has proxy, and for using internet we should enter username and password to use internet.

how to write a program to pass proxy server in vb.net?

what is problem with my code???
error 407!!!
:(

Dim sResult As String
Dim objResponse As WebResponse
Dim objRequest As WebRequest = System.Net.HttpWebRequest.Create(URL)


oProxy.Credentials = New NetworkCredential(UserName, PassWord, Domain)
objRequest.Proxy = oProxy

objRequest.Method = "GET"
objRequest.Timeout = 120000 '' 20 sec.
objResponse = objRequest.GetResponse

Dim sr As System.IO.StreamReader = New StreamReader(objResponse.GetResponseStream(), System.Text.Encoding.UTF7)

sResult = sr.ReadToEnd()
sr.Close()

查看该错误表明它是代理身份验证错误.
googling that error shows that its a proxy authentication error.


请看一下此代码项目的讨论:

http://www.codeproject.com/Messages/3000519/Re-WebRequest-GetResponse-equals-error-407-Proxy-A.aspx [
Take a look at this codeproject discussion:

http://www.codeproject.com/Messages/3000519/Re-WebRequest-GetResponse-equals-error-407-Proxy-A.aspx[^]

try using

poProxy.Credentials = CredentialCache.DefaultCredentials


代替


instead of

oProxy.Credentials = New NetworkCredential(UserName, PassWord, Domain)