Forum Moderators: open

Message Too Old, No Replies

Add post data with VB

         

andrewsmd

6:21 pm on Nov 2, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Does anyone have a quick and dirty example of how to add POST data to a url and send it. I have a system right now that allows users to add/edit/delete jobs. Careelink has a url that I can post data to and it will automatically add these jobs to a user's account. In php I would use CURL. Is there a vb equivalent? Thanks,

Ocean10000

12:49 am on Nov 3, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I found a nice example of a Vb.Net http post application along with basic how to use it examples.

[winsocketdotnetworkprogramming.com...]

marcel

8:10 am on Nov 3, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Here is a quick and dirty method of doing it:

Dim myWebClient As New System.Net.WebClient()

myWebClient.Headers.Add("Content-Type", "application/x-www-form-urlencoded")

Dim postQuery As Byte() = System.Text.Encoding.ASCII.GetBytes("action=login&username=marcel&password=password")
Dim theResponse As Byte() = myWebClient.UploadData("http://www.webmasterworld.com/login.cgi", "POST", postQuery )

Response.Write(System.Text.Encoding.ASCII.GetString(theResponse))

* this will post to the WebmasterWorld login form, and you should temporarily see that you are logged in. (if you use the correct credentials of course :) )

andrewsmd

8:36 pm on Nov 3, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Thanks your example was exactly what I needed.