473,395 Members | 1,568 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

post programmatically

Hi

I want to programmatically perform a post. Can some one please give me
some pointers to which classes I need to use to achieve this?

The form which is normally posted from the website looks like the
following, but I want to do it programmatically.
<form action="https://intl.payments/recdpay" method="POST"
target="_top">
<input type="hidden" name="merchantID" value="xx7223.189" />
<input type="hidden" name="orderID" value="UK_Z0000287" />
<input type="hidden" name="amount" value="59995" />
<input type="hidden" name="currencyCode" value="GBP" />
<input type="hidden" name="cardType" value="6" />
<input type="submit" value="Pay" />
</form>

Thanks,
Peter
Sep 3 '08 #1
3 2253

"Peter" <xd****@hotmail.comwrote in message
news:ux**************@TK2MSFTNGP05.phx.gbl...
Hi

I want to programmatically perform a post. Can some one please give me
some pointers to which classes I need to use to achieve this?

The form which is normally posted from the website looks like the
following, but I want to do it programmatically.
HttpWebRequest should do the trick, just don't forget to set its Method to
"POST". Values of form controls go into the request body, which is just a
stream for WebRequest, so you'll need to format it yourself. W3C HTML 4.01
spec has detailed description of the format:

http://www.w3.org/TR/html4/interact/forms.html#h-17.13
Sep 3 '08 #2
On Sep 3, 6:16*pm, "Peter" <xdz...@hotmail.comwrote:
Hi

I want to programmatically perform a post. Can some one please give me
some pointers to which classes I need to use to achieve this?

The form which is normally posted from the website looks like the
following, but I want to do it programmatically.

<form action="https://intl.payments/recdpay" method="POST"
target="_top">
<input type="hidden" name="merchantID" value="xx7223.189" />
<input type="hidden" name="orderID" value="UK_Z0000287" />
<input type="hidden" name="amount" value="59995" />
<input type="hidden" name="currencyCode" value="GBP" />
<input type="hidden" name="cardType" value="6" />
<input type="submit" value="Pay" />
</form>

Thanks,
Peter
As Pavel Minaev said, HttpWebRequest would be good enough. But
WebRequest is also good, I think. Basically, as far as I know,
HttpWebRequest is a superset of WebRequest. You can find many samples
for it, even the .NET documentation had a section about how to POST a
request at the How do I section.

To save your time, I will write a quick code for you, may contain some
errors, but you can start it from there.

WebRequest req = WebReqest.Create("https://....");
req.Method="POST"; <-Default is GET, so need to specify "POST"
req.ContentType="application/x-www-form-urlencoded"; <-This is
required because there are other types of forms like multipart or
something.
Stream s = req.GetRequestStream();
string data="merchantID=xx7223.189&orderID....";
byte[] binaryData=Encoding.UTF8.GetBytes(data); <-Supposing the page's
encoding is UTF-8. Need to change it in other cases.
s.Write(binaryData,0,binaryData.Length);
s.close();
req.ContentLength=binaryData.Length;
WebResponse res =req.GetResponse();
Sep 3 '08 #3
"Sin Jeong-hun" <ty*******@gmail.comwrote in message
news:1d**********************************@z11g2000 prl.googlegroups.com...
On Sep 3, 6:16 pm, "Peter" <xdz...@hotmail.comwrote:
As Pavel Minaev said, HttpWebRequest would be good enough. But
WebRequest is also good, I think. Basically, as far as I know,
HttpWebRequest is a superset of WebRequest. You can find many samples
for it, even the .NET documentation had a section about how to POST a
request at the How do I section.
WebRequest is an abstract class, HttpWebRequest is one specific
implementation.

It is generally advised to use WebRequest.Create() factory method to
instantiate any implementation of WebRequest. But it is explicitly allowed
to cast the return value of WebRequest.Create() to the specific type you
expect to get.

In this case though, I've missed the fact that WebRequest has property
Method already (strange, since it's really HTTP-specific, and cannot be
properly used in a generic fashion anyway), so no need for cast.
Sep 4 '08 #4

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

Similar topics

0
by: Dan Greenblatt | last post by:
I am trying to programmatically manipulate the menus in my application, for purposes of a tutorial, showing users where things are in our application's menu interface. My goal is to be able to...
1
by: DM | last post by:
I have a user control that contains a DropDownList and a Submit Button. In the Page_Load method of the User Control, I populate the Drop Down List. When the user clicks on the submit button, I need...
6
by: Ben | last post by:
Hi I need to design a form that I can programmatically post using this code from a VB .NET Windows Application: Dim web As New System.Net.WebClient() web.Headers.Add("Content-Type",...
3
by: WJ | last post by:
1. How can I use POST method to post the following XML statements to an Html page or Asp page using Asp.net or 2. If the XML below is a file (text), how do I POST it to other web site...
7
by: | last post by:
Hello, I would like to do the following from a asp.net button click: <form method="POST" action="https://www.1234.com/trans_center/gateway/direct.cgi"> <input type="hidden" name="Merchant"...
8
by: Gert | last post by:
Hi, I have a form (server side) because of the filling of variables through the application. But now I need to post it to an url on submit. My .HTML form looks like this, but how to translate it...
4
by: David Veeneman | last post by:
I want to programmatically create some POST data on a web server, then pass that data to another web page that the server calls, using Server.Transfer(). What's the best way to do that? I'm...
7
JodiPhillips
by: JodiPhillips | last post by:
Hi, My first post! I've basically taught myself Access and the little I know about VBA through reading these forums and a couple of books. I'm in the middle of a project at work - to put it...
2
by: David | last post by:
Hello, I would like to know how to post form data programmatically. The idea is to get the intranet web page, programmatically entre the username and password in a login form, post it and be...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
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,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.