need to simulate a form submit with action=post from 2.0 (vb)

I'm working with a vendor who require I send info through a form post.  I cannot just stick in an asp classic page with a html form as there is some database interaction AFTER the user has completed the form that provides one of the values to be sent.

I think this uses the HTTPRequest Object but ... Sample code would be great.

Thanks in advance
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

HTTPRequest is one way to do it, but a more common way is with Webclient.  It's hard to provide sample code when I don't know what the purpose of the request is.  i.e. upload data, download data, what type of data, etc.  The sample below takes a string for posting and returns a string:

Dim Address As String = "http://..."
Dim objInf As String = "..."
Dim objBytes As Byte() = System.Text.Encoding.ASCII.GetBytes(objInf)
Dim objRequest As New WebClient
Dim objRetBytes As Byte()
Dim objRetInf As String
objRetBytes = objRequest.UploadData(Address, "POST", objBytes)
objRetInf = System.Text.Encoding.ASCII.GetString(objRetBytes)

Similarly, if you're working with name-value collections:

Dim objRequest As New WebClient()
Dim objInf As New System.Collections.Specialized.NameValueCollection(1)
Dim objRetBytes() As Byte
Dim objRetVals() As String
objRequest.BaseAddress = "http://..."
objInf.Add("key", "value")
objRetBytes = objRequest.UploadValues(objRequest.BaseAddress, "POST", objInf)
objRetVals = System.Text.Encoding.ASCII.GetString(objRetBytes).Split(",".ToCharArray())

Hopefully you're getting the idea...

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
I forgot to mention...

Namespaces to import are System.Net and System.IO
goknowsAuthor Commented:
This does work and get's me half way there ... I need to not only submit the data (name-values pairs), but also navigate to the page (with my values in the header) exactly as if the had clicked a submit button on an html form

I want to mimic the functionality of a form like this:
<form id="sas" action="post">
<input id="somekey" name="somekey" type="hidden" value="boo">
<input id="Submit1" type="submit" value="submit" />

but programatically populate the header info and the go there in a server side script.

Thanks in Advance
Hmmm...  I can't think of a way to do that exactly.

Here's a thought though:

Dim objRequest As New WebClient()
Dim objInf As New System.Collections.Specialized.NameValueCollection(1)
Dim objRetBytes() As Byte
objRequest.BaseAddress = "http://..."
objInf.Add("key", "value")
objRetBytes = objRequest.UploadValues(objRequest.BaseAddress, "POST", objInf)
Response.Buffer = True

I haven't tested this code, so there's probably a syntax error or two in it, but you get the idea.

One BIG problem with this code though.  The location in the browser will still reflect that of the original page, not the page you redirected to.  If you don't care about that, this will work.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.