Posted By

bcmoney on 12/10/10


Tagged

http ASP aspnet dotnet proxy vbscript Classic


Versions (?)

proxy.asp


 / Published in: ASP
 

URL: http://bcmoney-mobiletv.com/blog/2009/05/01/the-server-side-proxy/

Classic ASP with VBscript (i.e. ASP.net before dominance of C#), some resources used:

http://www.webcheatsheet.com/asp/getcurrentpage_url.php

http://support.microsoft.com/kb/290591

http://w3schools.com/asp/asp_examples.asp

http://msdn.microsoft.com/en-us/library/ms762278(VS.85).aspx

http://www.mikesdotnetting.com/Article/39/AJAX-and-Classic-ASP

http://www.w3enterprises.com/articles/aspnet.aspx

http://www.asp101.com/samples/winhttp5.asp

http://www.devarticles.com/c/a/ASP/An-Introduction-To-XML-SOAP-Using-ASP-and-VB6/

http://www.tizag.com/aspTutorial/aspVBScript.php

http://classicasp.aspfaq.com/general/how-do-i-read-the-contents-of-a-remote-web-page.html

  1. <%@LANGUAGE="VBSCRIPT"%>
  2. <%
  3. 'gather the required Query Parameters URL, Format, Encoding
  4. dim url
  5. url = Request.QueryString("url")
  6. If url<>"" Then
  7. url = "http://example.com"
  8. End If
  9.  
  10. dim format
  11. format = Request.QueryString("f")
  12. If format<>"" Then
  13. format = "text/plain"
  14. End If
  15.  
  16. dim encoding
  17. encoding = Request.QueryString("e")
  18. If encoding<>"" Then
  19. encoding = "UTF-8"
  20. End If
  21.  
  22.  
  23. 'create a unique instance NONCE to ensure proxied calls are not cached
  24. dim instanceID
  25. instanceID = Session.SessionID
  26.  
  27.  
  28. 'perform the HTTP Request
  29. dim xmlhttp
  30. set xmlhttp = server.Createobject("MSXML2.ServerXMLHTTP")
  31. xmlhttp.Open "GET",url&"instanceID="&instanceID,false 'IF doing a POST: use --> "POST",url,false
  32. '"": set DataToSend = value then call ---> xmlhttp.send DataToSend
  33. '"": also set Content-Type of POST body ---> xmlhttp.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
  34.  
  35.  
  36. 'display the response
  37. Response.ContentType = format 'May want to check IF ContentType == "text/xml"
  38. Response.Charset = encoding 'UTF-8 should be fine for most uses unless not supported, then go with:
  39. Response.Write xmlhttp.responseText 'IF ContentType == "text/xml": Response.Write xmlhttp.responsexml.xml
  40. Response.End()
  41. Set xmlhttp = nothing
  42.  
  43. %>

Report this snippet  

You need to login to post a comment.