Forum Moderators: open

Message Too Old, No Replies

Any way to send POST data from ASP...or .NET?

         

lwoods

3:41 pm on Sep 24, 2004 (gmt 0)

10+ Year Member



I need to send data to a URL that cannot be seen in the Address of a browser; i.e., POST vs. GET. I do not have any control over the destination site, only the source page. And, I don't want the user to see any of the parameters so just submitting a FORM is out of the question.

Any ideas?

TIA

Lord Majestic

3:45 pm on Sep 24, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



HttpWebRequest class in .NET is your friend (enough examples on the net to write a new one).

mattglet

8:16 pm on Sep 24, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Classic ASP:

strPostURL = "http://www.example.com/posthere.asp"
strPost = "variable1=value1&variable2=value2"

set objPost = Server.CreateObject("MSXML2.ServerXMLHTTP.3.0")
objPost.Open "POST", strPostURL, false
objPost.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
objPost.send strPost

strTheResponse = objPost.responseText

lwoods

11:22 pm on Sep 24, 2004 (gmt 0)

10+ Year Member



Re: Classic ASP. I tried this but what I am trying to do is go to PayPal without exposing my values. Therefore, I won't be returning. This is where I ran into problems using ServerXMLHTTP.

Comments?

TIA

lwoods

2:24 am on Sep 25, 2004 (gmt 0)

10+ Year Member



Additional explanation:

I am trying to "redirect" to PayPal, therefore there will not be an response. Using the .NET control does not allow me to relinquish control as far as I can see.

TIA

MozMan

4:06 pm on Sep 29, 2004 (gmt 0)

10+ Year Member



lwoods- This may be the worst possible way to do this, but I'm not done with my coffee and can't think of anything else at the moment. Anyway, my idea is this:

Create a hidden form using post, and use ASP to populate the form values. Then simply use some javascript to submit.

It might go something like below. I'm not certain it will work, because doing it this way, your submit might happen before you form is created, but it's worth investigating.


<%
'ASP stuff here to get values into strValue1 and strValue2
%>
<html>
<head>
<script language='javascript'>
function MoveAlong()
{
document.frmForm.submit()
}
</script>
</head>
<body onload='MoveAlong()'>
<form name='frmForm' method='post' action='http://www.detinationurl.com'>
<input type='hidden' name='hidValue1' value='<%=strValue1%>'>
<input type='hidden' name='hidValue2' value='<%=strValue2%>'>
</form>
</body>

Anyway, it's ugly, but it might do the trick...

-Moz.