VB6 Post example using ASP to extract the form value that has been posted
Please Wait
I am using VB6 and WinHTTP. I couldn't get the VB POST example to work and I found that I needed
to set the HTTP verb to POST not PUT and that the header needs to be set to "application/x-www-form-urlencoded"
So my example code is:
sub httpPost()
Dim HttpReq As New WinHttpRequest
HttpReq.Open "POST", "http://localhost/test.asp", False
HttpReq.SetRequestHeader "Content-Type", "application/x-www-form-urlencoded"
HttpReq.Send "fld1234=Rabbits"
Debug.Print HttpReq.ResponseText
end sub
with test.asp:
<html>
<head>
</head>
<body>
Value posted was: <%= request.form("fld1234") %>
</body>
</html>
The Send data needs URLEncoding and there are plenty of examples about of code to do this.
I used Netmon (which is a lot easier than I imagined) and a remote host to identify what
was going wrong with the post comparing it with a post that worked in IE6.