如何在 Classic ASP 中将数据发布到远程 URL? [英] How do I POST data to a remote URL in Classic ASP?

查看:15
本文介绍了如何在 Classic ASP 中将数据发布到远程 URL?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要 POST 数据到脚本中间的一个 url.

I need to POST data to a url in the middle of a script.

  1. 用户填写表格:
  2. 表单提交到 process.asp:此时我需要 POST 数据到第 3 方集成.
  3. process.asp 完成并引导用户访问感谢页面.
  1. User fills out form:
  2. Form submits to process.asp: I need to POST data to a 3rd Party integration at this point.
  3. process.asp finishes and directs user to thank you page.

推荐答案

我不知道为什么其他人都在发布 ASP.Net 解决方案,而您明确表示您使用的是 ASP经典".

I'm not sure why everybody else is posting ASP.Net solutions when you specifically said you're using ASP "classic."

这样的事情应该可以工作.我没有写代码;我在别处找到的.但是,如果您不想购买商业产品,则可以使用 MSXML2.ServerXMLHTTP 对象.

Something like this should work. I didn't write the code; I found it elsewhere. But the MSXML2.ServerXMLHTTP object is what you want to use if you don't want to purchase something commercial.

function getHTML (strUrl)
    Set xmlHttp = Server.Createobject("MSXML2.ServerXMLHTTP")
    xmlHttp.Open "GET", strUrl, False
    xmlHttp.setRequestHeader "User-Agent", "asp httprequest"
    xmlHttp.setRequestHeader "content-type", "application/x-www-form-urlencoded"
    xmlHttp.Send
    getHTML = xmlHttp.responseText
    xmlHttp.abort()
    set xmlHttp = Nothing   
end function 

您可能需要添加一些错误处理代码,以便在生产环境中使用.我相信如果对象收到 404 或超时错误,它会引发错误.您需要通过在 .Send 之前设置 On Error Resume Next 来捕获"它们 ASP 样式(糟糕),然后检查 ASP 错误对象以查看是否存在问题.

You might need to add some error-handling code to that for use in a production environment. I believe that object throws errors if it gets a 404 or timeout error. You'll need to "trap" them ASP-style (yuck) by setting On Error Resume Next before the .Send and then examine the ASP error object to see if there was a problem.

祝你好运!

这篇关于如何在 Classic ASP 中将数据发布到远程 URL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆