How do I mask my webclient with a proxy? I need to download a page, but I need to download it with a specified proxy. Any help?
Printable View
How do I mask my webclient with a proxy? I need to download a page, but I need to download it with a specified proxy. Any help?
Code:Dim MyWebClient As New Net.WebClient
Dim MyWebProxy As New Net.WebProxy
Dim MyCredentials As New Net.NetworkCredential
With MyCredentials
.UserName = "kleinma"
.Password = "secret"
End With
With MyWebProxy
.Address = New Uri("proxy addr here")
.Credentials = MyCredentials
.BypassProxyOnLocal = True 'or false
End With
MyWebClient.Proxy = MyWebProxy
Thakns very much, resolved
When i use this in VS 2010
then i get a warning:
Warning 1 Variable 'Mywebproxy' is used before it has been assigned a value. A null reference exception could result at runtime.
Please help me with this.
The only reason you would get a warning like that is if you forgot to put the "New" keyword in the line that declares the myWebProxy variable. If you retyped the example code and didn't copy/paste it, then that is likely your issue.
thank you
I got it