Need help with a WebClient() error

A

Anthony P.

Hello Everyone,

I'm trying to send a GET request via a WebClient object. Here is the
code I'm using to do that:

Dim submitURL = "http://" & frmMain.txtNetworkServer.Text _
& "/tweetfree/server.php?key=" &
frmMain.txtNetworkKey.Text _
& "&tweet=" & dataFromClient

Dim oWebClient As System.Net.WebClient = New
System.Net.WebClient()
Dim sResult As String = oWebClient.DownloadString
(submiturl)

But, whenever my application hits that block of code, I get this
error:

http://img154.imageshack.us/i/screenshotvki.jpg/

I've spent the last few hours googling and can't seem to find the
answer. Any idea what this might mean? And, how do I fix it?

Thanks,
Anthony Papillion
 
T

Tom Shelton

Hello Everyone,

I'm trying to send a GET request via a WebClient object. Here is the
code I'm using to do that:

Dim submitURL = "http://" & frmMain.txtNetworkServer.Text _
& "/tweetfree/server.php?key=" &
frmMain.txtNetworkKey.Text _
& "&tweet=" & dataFromClient

Dim oWebClient As System.Net.WebClient = New
System.Net.WebClient()
Dim sResult As String = oWebClient.DownloadString
(submiturl)

But, whenever my application hits that block of code, I get this
error:

http://img154.imageshack.us/i/screenshotvki.jpg/

I've spent the last few hours googling and can't seem to find the
answer. Any idea what this might mean? And, how do I fix it?

Thanks,
Anthony Papillion

Try something like:
Dim submitURL = "htt://" & frmMain.txtNetworkServer.Text & _
"/tweetfree/server.php?key=" & _
HttpUtility.UrlEncode(frmMain.txtNetworkKey.Text) & "&tweet=" & _
HttpUtility.UrlEncode(dataFromClient)

Anyway, there are characters that are illegal in a url - and they need to be
encoded. HttpUtility can handle the encoding for you - but, you'll need to
add a reference to system.web.dll :)
 
A

Anthony Papillion

Anyway, there are characters that are illegal in a url - and they need tobe
encoded.  HttpUtility can handle the encoding for you - but, you'll need to
add a reference to system.web.dll :)

Hi Tom,

Thanks for the information. That worked for me! The other problem I
was having, which was accessing the contents of a textbox from another
thread, was solved by simply creating a new module, adding a few
Friend vars and then assigning the value of the textbox to the Friend
vars before I went into the other thread.

Thanks for the info though, my application is now very close to being
finished!

Anthony Papillion
 

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