2014-05-13 38 views
0

我想从一个asp页面发送一些数据到另一个页面。我试过使用下面的代码,尽管我没有任何编译错误,但我的request.aspx页面似乎并没有收到数据。出了什么问题?使用ServerXMLHTTP发送数据从ASP到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 
+0

那你在浏览器的网络跟踪窗口看到,当你的ASP页面发出请求?任何错误返回? – sh1rts

回答

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

相关问题