Click here to Skip to main content
15,885,875 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
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()
Posted
Updated 29-Sep-10 4:32am
v2

googling that error shows that its a proxy authentication error.
 
Share this answer
 
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)
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900