Advertisement

07.01.2008 at 07:05AM PDT, ID: 23530172
[x]
Attachment Details

Using HttpWebRequest/Response correctly?

Asked by directxBOB in Programming for ASP.NET

I am trying to convert:

<form action=https://someprovider/somepage.cgi method=post>

<input type=hidden name="MERCHANT_ID" value="<%=merchantid%>">
<input type=hidden name="ORDER_ID" value="<%=orderid%>">
<input type=hidden name="CURRENCY" value="<%=curr%>">
<input type=hidden name="AMOUNT" value="<%=amount%>">
<input type=hidden name="TIMESTAMP" value="<%=timestamp%>">
<input type=hidden name="SHA1HASH" value="<%=sha1hash%>">
<input type=hidden name="AUTO_SETTLE_FLAG" value="1">

<input type=submit value="Proceed to secure server">
</form>

This is essentially an ASP page which displays a button and when clicked sends these hidden fields onto a provider who handle the sale (much like how paypal works).

The problem I am having is this is an ASP page and I am trying to bring it forward be an .NET based piece of code.

The issue I am having is that

<input type=submit value="Proceed to secure server">

Is not an ASP tag and as a result I don't have an event to bind the various fields to be sent across. One idea I was thinking of using was to create a HttpWebRequest and pad in that data, but unfortunately I have no idea where to start or what to do. It can be assume that all the above fields are textboxes on my page..

I have the below code also but I am not exactly sure how I adapt it to my needs. (Take data on a click event and post it to another page on another server).

Any help would be greatly appreciated.

Cheers
RonanStart Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
//http://www.netomatix.com/HttpPostData.aspx
 
private void OnPostInfoClick(object sender, System.EventArgs e)
{
	string strId = UserId_TextBox.Text;
	string strName = Name_TextBox.Text;
 
	ASCIIEncoding encoding=new ASCIIEncoding();
	string postData="userid="+strId;
	postData += ("&username="+strName);
	byte[]  data = encoding.GetBytes(postData);
 
	// Prepare web request...
	HttpWebRequest myRequest =
	  (HttpWebRequest)WebRequest.Create("http://localhost/MyIdentity/Default.aspx");
	myRequest.Method = "POST";
	myRequest.ContentType="application/x-www-form-urlencoded";
	myRequest.ContentLength = data.Length;
	Stream newStream=myRequest.GetRequestStream();
	// Send the data.
	newStream.Write(data,0,data.Length);
	newStream.Close();
}
[+][-]07.02.2008 at 10:28AM PDT, ID: 21918693

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: Programming for ASP.NET
Sign Up Now!
Solution Provided By: Rejojohny
Participating Experts: 1
Solution Grade: A
 
 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628