473,765 Members | 2,081 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

POSTing Data to another server

I am in a situation where I need to package some information from
Page1, submit it via POST to another server which will process the
information and then send the user to another page on my server
(Page2).

I have looked at HttpWebRequest (see code below) on numerous coding
websites but have not found a method that works. Does anyone have a
solution for this or has seen an example that works for this
situation?

Currently, I am using an HTML page that obviously goes away when it
performs the POST. I need the ASP.NET page to work the same way--send
the data and go away. The receiving server is configured to send data
back to a page on my server.

This is one very frustrating issue that I have with ASP.NET--the
postback architecture gets wrapped around itself for something like
this.
Thanks,
Mike

private void btnSubmit_Click (object sender, System.EventArg s e)
{
string bname = tbName.Text;
string baddr1 = tbAddress.Text;
string bcity = tbCity.Text;
string bstate = ddlState.Select edItem.Value;
string bzip = tbZip.Text;
string phone = tbPhone.Text;
string email = tbEMail.Text;
string cctype = ddlCCType.Selec tedItem.Value;
string cardnumber = tbCCNumber.Text ;
string expmonth = ddlExpMonth.Sel ectedItem.Value ;
string expyear = ddlExpYear.Sele ctedItem.Value;
string subtotal = lblCost.Text.Su bstring(1);
string tax = lblTax.Text.Sub string(1);
string chargetotal = lblTotal.Text.S ubstring(1);

string postData = "bname=" + Server.UrlEncod e(bname);
postData += "&baddr1=" + Server.UrlEncod e(baddr1);
postData += "&bcity=" + Server.UrlEncod e(bcity);
postData += "&bzip=" + Server.UrlEncod e(bzip);
postData += "&phone=" + Server.UrlEncod e(phone);
postData += "&email=" + Server.UrlEncod e(email);
postData += "&cctype=" + Server.UrlEncod e(cctype);
postData += "&cardnumbe r=" + Server.UrlEncod e(cardnumber);
postData += "&expmonth= " + Server.UrlEncod e(expmonth);
postData += "&expyear=" + Server.UrlEncod e(expyear);
postData += "&subtotal= " + Server.UrlEncod e(subtotal);
postData += "&tax=" + Server.UrlEncod e(tax);
postData += "&chargetot al=" +
Server.UrlEncod e(chargetotal);
postData += "&storename=XXX XXXXXXX";
postData += "&mode=payplus" ;
postData += "&txnorg=ec i";
postData += "&bcountry= US";
postData += "&2000=subm it";

HttpWebRequest postReq = (HttpWebRequest )
WebRequest.Crea te("https://staging.linkpt. net/lpc/servlet/lppay");
postReq.Method = "POST";
postReq.AllowAu toRedirect = false;
postReq.Content Type = "applicatio n/x-www-form-encoded";
postReq.Content Length = postData.Length ;

byte[] buffer = Encoding.UTF8.G etBytes(postDat a);
using (Stream reqst = postReq.GetRequ estStream())
{
reqst.Write(buf fer, 0, buffer.Length);
}
}
Jul 21 '05 #1
0 1648

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
1840
by: anon | last post by:
Post Forwarding question...... For this control below, <asp:Button runat="server" PostTargetUrl="page2.aspx" /> The Attribute: PostTargetUrl="page2.aspx" Is this PostTargetUrl Attribute going to be available in the <a> and Html Controls as well as opposed to just the <asp:Button> control?
10
4189
by: DaveFash | last post by:
Posting variables from an HTML FORM, via the Request.Form function on the receiving ASP page is great. But how can you POST a Form variable to an ASP page -- without a human pushing a Submit button? An ASP page that can decide when to POST and send the Form vaiables, but out without a
3
1303
by: Brian Shannon | last post by:
Lets say I have web1.aspx which the user inputs data into txtData (text box). When the user clicks the button ADD the browser takes the user to web2.aspx. On web2.aspx I need to post the data entered from the first page. Is it best to use a querystring, session variable or is there a better alternative. Currently I use session variables for a lot of my work but want to get away from that since there are better alternatives. Thanks
2
1740
by: ejs | last post by:
Please read the entire reponse, hopefully this clears up your questions. The data used that needs to go into the batchupload page comes from a server. My problem is that currently I write a file to the server and then the user has to pick this file and send it up to the batchupload page. The batchupload page is not one of our page, instead it is another company's page. This is there interface to do batch processing. We have no control...
0
253
by: someone | last post by:
I am in a situation where I need to package some information from Page1, submit it via POST to another server which will process the information and then send the user to another page on my server (Page2). I have looked at HttpWebRequest (see code below) on numerous coding websites but have not found a method that works. Does anyone have a solution for this or has seen an example that works for this situation?
0
1664
by: Stefan Schwarzer | last post by:
Hi all! For my FTP library module ftputil , some users have asked for a way to avoid server timeouts (FTP status code 421). But I haven't found out yet how I can do this in all cases. I try to explain the problem in more detail. The following is rather special and probably not so easy to understand, but I'll do my best. Please ask if you need more information.
5
1322
by: dana lees | last post by:
Hi, I am writing a C# asp.net application. How can i post files to a web page? Can you please show an example? I have 3 input files: for example - <input type="file" size="40" id="file1" runat="server">
5
1119
by: vaj | last post by:
Hey, Im creating a system on a pocket pc based on win ce 4.2 and i need to tranfer three datasets to a remote server on the network.Could anyone tell me the easiest way to do this? cheers, -vaj
0
2637
by: kwilliams1130 | last post by:
I am having a problem with data that is being posted to another server. The problem is I collect the data from our database through an .cfm file (and all data is correct), which then the data is saved to an .xml document and posted to another server though an .asp file. The problem is the other server is either not receiving the data (it says it exports without an problems on our end) or it is not receiving the data correctly. The only...
0
9568
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9398
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10156
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10007
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9832
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7375
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6649
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5419
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3531
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.