Asp classic 如何在asp中发送和处理Http Post?

Asp classic 如何在asp中发送和处理Http Post?,asp-classic,Asp Classic,如何处理以上代码的帖子。在handle.asp中。在handle中,我想获取正在发送的数据并添加到其中,然后将一些内容发送回调用页面?@Uzi:下面是一个示例-- somefile.asp调用handle.asp这是处理脚本: httpRequest.Open "POST", "www.example.com/handle.asp", False httpRequest.setRequestHeader "Content-Type", "application/x-www-form-urlenc

如何处理以上代码的帖子。在handle.asp中。在handle中,我想获取正在发送的数据并添加到其中,然后将一些内容发送回调用页面?

@Uzi:下面是一个示例--

somefile.asp
调用
handle.asp
这是处理脚本:

httpRequest.Open "POST", "www.example.com/handle.asp", False
httpRequest.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
httpRequest.send data
postResponse = httpRequest.response
handle.asp
示例:

Option Explicit

Dim data, httpRequest, postResponse

data = "var1=somevalue"
data = data & "&var2=someothervalue"
data = data & "&var3=someothervalue"

Set httpRequest = Server.CreateObject("MSXML2.ServerXMLHTTP")
httpRequest.Open "POST", "http://www.example.com/handle.asp", False
httpRequest.SetRequestHeader "Content-Type", "application/x-www-form-urlencoded"
httpRequest.Send data

postResponse = httpRequest.ResponseText

Response.Write postResponse ' or do something else with it

正如您通常在ASP中通过使用
Request.Form(“参数”)
读取发布的值并对其执行任何操作来处理发布的数据一样

您只需要确保从处理脚本返回的数据的格式可以由发出POST请求的脚本轻松解码/使用

Option Explicit

Dim var1, var2, var3

var1 = Request.Form("var1")
var2 = Request.Form("var2")
var3 = Request.Form("var3")

' Silly example of a condition / test '
If var1 = "somecondition" Then
    var1 = var1 & " - extra text"
End If

' .. More processing of the other variables .. '

' Processing / validation done... '
Response.Write var1 & vbCrLf
Response.Write var2 & vbCrLf
Response.Write var3 & vbCrLf