本文介绍了如何执行ASP HTTP POST请求?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将如何去创造与传统的ASP(而不是.NET)?

How would I go about creating a HTTP request with POST data in classic asp (not .net) ?

推荐答案

您可以尝试这样的事情:

You can try something like this:

Set ServerXmlHttp = Server.CreateObject("MSXML2.ServerXMLHTTP.6.0")
ServerXmlHttp.open "POST", "http://www.domain.com/page.asp"
ServerXmlHttp.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
ServerXmlHttp.setRequestHeader "Content-Length", Len(PostData)
ServerXmlHttp.send PostData

If ServerXmlHttp.status = 200 Then
    TextResponse = ServerXmlHttp.responseText
    XMLResponse = ServerXmlHttp.responseXML
    StreamResponse = ServerXmlHttp.responseStream
Else
    ' Handle missing response or other errors here
End If

Set ServerXmlHttp = Nothing

在哪里是的PostData您要发布的数据(如名称 - 值对,XML文档或其他)。

where PostData is the data you want to post (eg name-value pairs, XML document or whatever).

您需要设置MSXML2.ServerXMLHTTP的正确版本,以配合您所安装的。

You'll need to set the correct version of MSXML2.ServerXMLHTTP to match what you have installed.

开放式方法有五个参数,其中只需要前两个:

The open method takes five arguments, of which only the first two are required:

ServerXmlHttp.open Method, URL, Async, User, Password


  • 方法:GET或POST

  • 网址:你想要的网址张贴到

  • 异步:默认值为False(电话不会立即返回) - 设置为True异步调用

  • 用户:认证所需的用户名

  • 密码:认证所需的密码

  • 当调用返回时,状态属性包含HTTP状态。值200表示OK - 404表示未找到,500表示服务器错误等(见<一href=\"http://en.wikipedia.org/wiki/List_of_HTTP_status_$c$cs\">http://en.wikipedia.org/wiki/List_of_HTTP_status_$c$cs为其他的值。)

    When the call returns, the status property holds the HTTP status. A value of 200 means OK - 404 means not found, 500 means server error etc. (See http://en.wikipedia.org/wiki/List_of_HTTP_status_codes for other values.)

    您可以得到的回应是以文本(responseText属性),XML(responseXML属性)或流(responseStream属性)。

    You can get the response as text (responseText property), XML (responseXML property) or a stream (responseStream property).

    这篇关于如何执行ASP HTTP POST请求?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-19 17:47