我如何POST数据到经典的ASP远程URL? [英] How do I POST data to a remote URL in Classic ASP?

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

问题描述

我需要 POST 数据在脚本中间的网址。


  1. 用户填写表单:

  2. 表单提交给 process.asp中:我需要 POST 数据的第三方集成在这一点上。

  3. process.asp中结束,并指示用户感谢你的页面。


解决方案

我不知道为什么别人都张贴ASP.Net解决方案时,可以明确地说你正在使用ASP经典。

像这样的东西应该工作。我没有写code;我发现它在其他地方。但MSXML2.ServerXMLHTTP目标是要使用,如果你不想购买的东西是什么商业

 函数getHTML(strUrl)
    设置XMLHTTP =的Server.CreateObject(MSXML2.ServerXMLHTTP)
    xmlHttp.OpenGET,strUrl,假
    xmlHttp.setRequestHeader用户代理,ASP HTT prequest
    xmlHttp.setRequestHeader内容类型,应用程序/ x-WWW的形式urlen codeD
    xmlHttp.Send
    getHTML = xmlHttp.responseText
    xmlHttp.abort()
    设置XMLHTTP =什么
最终功能

您可能需要一些错误处理code添加到用于生产环境。我相信,如果它得到一个404或超时错误对象抛出错误。您可以通过设置在错误面前。发送下一恢复,然后检查ASP错误对象,看是否有问题需要陷阱他们ASP风格(呸)。

祝你好运!

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

  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.

解决方案

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

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

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.

Good luck!

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

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