使用ServerXMLHTTP Object将数据从ASP发送到ASPX页面

时间:2014-05-13 18:28:15

标签: asp.net vbscript asp-classic

我正在尝试将一些数据从一个asp页面发送到另一个页面。我尝试过使用下面的代码,虽然我没有任何编译错误,但我的request.aspx页面似乎没有收到数据。出了什么问题?

ASP页面发送数据:

Dim objHttp 
Dim str 

str = "request=Test" 

Set objHttp = Server.CreateObject("Msxml2.ServerXMLHTTP") 
objHttp.Open "POST", "https://address.com/request.aspx", false
objHttp.setRequestHeader "Content-Type", "application/x-www-form-urlencoded; charset=iso-8859-1"
objHttp.setRequestHeader "Content-Length", Len(str) 
objHttp.Send str 

Response.Write(objHttp.ResponseText) 

Set objHttp = nothing

ASPX页面接收数据:

Imports System.IO
Imports System.Threading

Partial Class request

Inherits System.Web.UI.Page

Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load

    Dim CurrentUser As MembershipUser = Membership.GetUser()
    Dim contentRequest As String = Context.Request.Form("request")

    'do something

End Sub
End Class

1 个答案:

答案 0 :(得分:0)

我的朋友,我认为这是" HTTPS"。

这是我的代码,它正在运作。

<%
    DataToSend = "id=1"

    dim xmlhttp 
    set xmlhttp = server.Createobject("MSXML2.ServerXMLHTTP")
    xmlhttp.Open "POST","http://localhost/Receiver.aspx",false
    xmlhttp.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
    xmlhttp.send DataToSend

    Set xmlhttp = nothing
%>

但是,看看那些帖子:

Can't use HTTPS with ServerXMLHTTP object

Getting XMLHTTP to work with HTTPS