ASP 101 - Active Server Pages 101 - Web03
The Place ASP Developers Go!

Windows Technology Windows Technology
15 Seconds
ASP 101
ASP Wire
VB Forums
VB Wire
internet.commerce internet.commerce
Partners & Affiliates
ASP 101 is an site
ASP 101 is an site
Internet News
Small Business
Personal Technology

Corporate Info
Tech Jobs
E-mail Offers

ASP 101 News Flash ASP 101 News Flash

ASP Source Code:
' This sample illustrates doing a behind the scenes
' HTTP POST to a web server.  If you're just looking
' to do a standard GET request or simply want more
' general information about making an HTTP request
' via ASP, please see:
' Our WinHTTP v5.x HTTP Request Sample
' Our Original HTTP Sample (mainly for discussion)
' Now on to the code...
Dim objWinHttp
Dim strResponseStatus
Dim strResponseText
' Create an instance of our HTTP object
Set objWinHttp = Server.CreateObject("WinHttp.WinHttpRequest.5.1")
' Open a connection to the server
'   .Open(bstrMethod, bstrUrl [, varAsync])
objWinHttp.Open "POST", "", False
' Set the content type header of our request to indicate
' the body of our request will contain form data.
'   .SetRequestHeader(bstrHeader, bstrValue)
objWinHttp.SetRequestHeader "Content-Type", "application/x-www-form-urlencoded"
' Send the request to the server.  Form data is sent in
' the body of the request.  Here I'm simply sending a
' name and a date.  You should URLEncode any data that
' contains spaces or special characters.
'   .Send(varBody)
objWinHttp.Send "Name=John&Date=" & Server.URLEncode(Now())
' Get the server's response status
strResponseStatus = objWinHttp.Status & " " & objWinHttp.StatusText
' Get the text of the response
strResponseText = objWinHttp.ResponseText
' Dispose of our object now that we're done with it
Set objWinHttp = Nothing
<strong>This page made an HTTP post request to:</strong><br />
<strong>It sent two pieces of data:</strong><br />
<code>Name</code> and <code>Date</code>
<strong>Response Status:</strong> <code><%= strResponseStatus %></code>
<strong>The Response:</strong>
<table border="1">
<%= strResponseText %>

Back the the Sample Output

Back to the Sample Index

Home |  News |  Samples |  Articles |  Lessons |  Resources |  Forum |  Links |  Search |  Feedback
The Network for Technology Professionals



Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | E-mail Offers