views:

86

answers:

0

I am making a request from a web server for some text and displaying it in a textbox using the following code:

    Dim client As WebClient = New WebClient()
    Dim theText As String = client.DownloadString("http://192.168.1.110/text.html")
    Me.TextBox1.Text = theText

When I run it the "client.DownloadString" command takes 6 or 7 seconds to complete (gets about 20 bytes of text). If I make this same request in a web browser it is basically immediate. I read a few related postings on other sites bout the proxy member (client.Proxy) needing to be null. Given VB.Net doesn't support null I set it to "Nothing" but there was no change in performance. Any ideas on why this is slow?

Update...yes, the request does succeed. It just takes 6 or 7 seconds. It is only slow the first time the call is made. If I delete the contents of the textbox and run it again, it is immediate. I have done some research on this and found that it has to do with setting the default proxy (client.Proxy) that it reads from the IE browser settings. Again, I've seen this problem addressed in other postings but never in VB.Net and the solution is always to set client.Proxy = Null. However, VB.Net doesn't support NULLs. I tried setting it to "Nothing" but it didn't seem to help.