I would like to know how I could write on the if statement to check with the proxy wether if they are required for the username and password?
Here it is the code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
' Create a new request to the mentioned URL.
Dim a As HttpWebRequest = DirectCast(HttpWebRequest.Create("http://whatismyip.com/automation/n09230945.asp"), HttpWebRequest)
' Obtain the 'Proxy' of the Default browser.
Dim Proxy As New WebProxy(Address1.Text, Integer.Parse(Ports.Text))
' Print the Proxy Url to the console.
Dim myProxy As New WebProxy()
If Address1.Text Is Nothing Then
MsgBox("plz enter the address and ports")
a.Proxy = New WebProxy(Address1.Text, Integer.Parse(Ports.Text))
Dim c As HttpWebResponse = DirectCast(a.GetResponse(), HttpWebResponse)
Dim reader As New StreamReader(c.GetResponseStream())
Dim ip As String = reader.ReadToEnd()
If Proxy.Credentials.GetCredential Then
myProxy.Credentials = New NetworkCredential(Username.Text, Password.Text)
a.Proxy = Proxy
Catch ex As Exception
MsgBox("proxy server fails")
As I am stored the username and password in the textbox. As the code I have already wrote, it won't response to the proxy by response with the us
View Complete Post