|
-
Jun 21st, 2013, 04:54 AM
#1
Thread Starter
Hyperactive Member
[RESOLVED] Using proxy with WebClient
Hi, I am looking into using a proxy with the WebClient.
The code I am trying is:
VB.NET Code:
Using WClient As New WebClient
WClient.Headers.Add(HttpRequestHeader.UserAgent, "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0)")
Dim WProxy As New WebProxy("<IP>:<Port>")
WClient.Proxy = WProxy
'I am using this website to test the current IP
MessageBox.Show(Encoding.UTF8.GetString(WClient.DownloadData("http://checkip.dyndns.org/")))
End Using
When I retrieve my IP from dyndns using the MessageBox above it is showing my own IP. Some of the proxy IP's I have tested use https so I also tried the code below:
VB.NET Code:
Private Shared Function BypassCertificate(ByVal sender As Object, ByVal cert As X509Certificate, ByVal chain As X509Chain, ByVal [error] As System.Net.Security.SslPolicyErrors) As Boolean
Return True
End Function
Private Sub TestProxy()
ServicePointManager.ServerCertificateValidationCallback = New System.Net.Security.RemoteCertificateValidationCallback(AddressOf BypassCertificate)
Using WClient As New WebClient
WClient.Headers.Add(HttpRequestHeader.UserAgent, "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0)")
Dim WProxy As New WebProxy("<IP>:<Port>")
WClient.Proxy = WProxy
MessageBox.Show(Encoding.UTF8.GetString(WClient.DownloadData("http://checkip.dyndns.org/")))
End Using
End Sub
However I still get the same result.
Am I doing this wrong? Or could it be that the proxy is working but that the IP lookup websites look beyond the proxy back to the source? If so, how would I test that it is working?
Thanks
Jay
-
Jun 21st, 2013, 05:17 AM
#2
Re: Using proxy with WebClient
My IP 86.9.199.38 Proxy <html><head><title>Current IP Check</title></head><body>Current IP Address: 64.78.30.2</body></html>
vb Code:
Imports System.Net
Imports System.Text
Public Class Form1
Private Sub TestProxy()
Dim proxy As New WebProxy("64.78.30.180:80")
Using wClient As New WebClient
wClient.Headers.Add("User-Agent", "Mozilla/5.0 (Windows NT 5.1; rv:13.0) Gecko/20100101 Firefox/13.0")
wClient.Proxy = proxy
Try
Me.RichTextBox1.Text = String.Format("My IP 86.9.199.38 Proxy {0}",
wClient.DownloadString(New Uri("http://checkip.dyndns.org/")))
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Using
End Sub
End Class
-
Jun 21st, 2013, 05:28 AM
#3
Thread Starter
Hyperactive Member
Re: Using proxy with WebClient
Your absolutely right. It seems there is nothing wrong with that code but rather the proxies I had tried. The site I grabbed them from has Transparent and Anonymous proxies. All my tests so far had been grabbing the Transparent ones.
Thanks for checking.
-
Jun 21st, 2013, 05:43 AM
#4
Re: [RESOLVED] Using proxy with WebClient
I was going to suggest make sure your proxy is not transparent. http://spys.ru/en/ Good luck.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|