Webrequest via Proxy

K

Kai Wiechers

....and here i am again! :(

I'm trying the whole afternoon and now I got a little closer to the solution
i hope...

I tryed webrequest again... ans tata! It worked. BUT not like i wanted it to
work :( I send a GET request and i got back "300", means for me a Answer I
can live with ;) But to get the connection working I had to bypass the
Proxyserver of my GPRS connection. Now you could say "ok, than delete the
proxy settings and everything works fine. have a nice day." . And yes,
normaly your right but i need this proxy configuration to connect to the
internet by a flatrate of my cellphone provider( o2 Germany). If i bypass
the proxy i have to extra pay the GPRS connection. If I'm using the proxy i
have to pay 5 Euro per Month and thats it. So I want to use this Proxy. This
Proxy only accepts HTTP connections on Port 8080.

If i delete the proxysettings in my device and use my testapp without
entering a proxy in txtProxy it worked.

If i delete the proxysettings in my device and use my testapp with entered
proxyinformation it don't worked.
If i dont delete the proxysettings in my device and use my testapp without
entered proxyinformation it don't worked.
If i dont delete the proxysettings in my device and use my testapp with
entered proxyinformation it don't worked.

If anybody can help me out... THANKS!

I copyed this code from the MSDN for my test application:

' Get URL and proxy
' from the text boxes.
txtURL.text = http://gateway.sms77.de/ 'line added by me because u cant
se the form
txtProxy.text = "195.182.114.52" 'line added by me because u cant se the
form
Dim url As String = txtURL.Text
Dim proxy As String = txtProxy.Text

Try
If Not "".Equals(txtProxy.Text) Then
Dim proxyObject As New WebProxy(proxy, 8080)

' Disable proxy use when the host is local.
proxyObject.BypassProxyOnLocal = True

' HTTP requests use this proxy information.
GlobalProxySelection.Select = proxyObject
End If

Dim req As WebRequest = WebRequest.Create(url)
Dim result As WebResponse = req.GetResponse()
Dim ReceiveStream As Stream = result.GetResponseStream()
Dim encode As Encoding = System.Text.Encoding.GetEncoding("utf-8")
Dim sr As New StreamReader(ReceiveStream, encode)

' Read the stream into arrays of 30 characters
' to add as items in the list box. Repeat until
' buffer is read.
Dim read(29) As [Char]
Dim count As Integer = sr.Read(read, 0, 30)
While count > 0
Dim str As New String(read, 0, count)
lstResults.Items.Add(str)
count = sr.Read(read, 0, 30)
End While
Catch ex As WebException
Dim message As String = ex.Message
Dim response As HttpWebResponse = CType(ex.Response,
HttpWebResponse)
If Nothing Is response Then
Else
message = response.StatusDescription
response.Close()
End If
lstResults.Items.Add(message)
Catch ex As Exception
lstResults.Items.Add(ex.Message)
End Try
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top