Hi,
I am not sure what exactly you want to do. A post request always submits the web form. Do you want to use Ajax style programming where you don't submit the webform but you have a request - response to the web server? Do you use ASP.NET? Java? JavaScript?
In a nutshell?
You use a XMLHttpRequest object in a Java script on your page. You do for example an XMLHttpRequestObject.open("GET", " http://localhost/somewhere/some_data.txt); which returns the content of the text file. This is really just scratching the surface!! There are books about Ajax and the Microsoft adoption ATLAS. I suggest for a start to get the book "Ajax for Dummies" (Yes, experts are allowed to read Dummie books, too) by Steve Holzner (ISBN 0471785970)
Let me know if you need to know more.
Cheers
Peter
|
|
Expert:
|
PeterNZ
|
|
Date:
|
Jul 19, 2006
|
|
Time:
|
21:56
|
|
|
|
Votes: Good (0) | Bad (0) Login to rate this answer
|
|
Hi Peter,
What I wanted to do was using ASP.NET (C#) submitting a form serverside, i.e. without actually creating an htm page and submitting that.
I found the answer and ended up with the following code:
string url = " http://websiteToSubmitTo";
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);
string proxy = null;
string data = String.Format("parameter1={0}¶meter2={1}¶meter3={2}", parameter1, parameter2, parameter3);
byte[] buffer = Encoding.UTF8.GetBytes(data);
req.Method = "POST";
req.ContentType = "application/x-www-form-urlencoded";
req.ContentLength = buffer.Length;
req.Proxy = new WebProxy(proxy, true); // ignore for local addresses
req.CookieContainer = new CookieContainer(); // enable cookies
Stream reqst = req.GetRequestStream(); // add form data to request stream
reqst.Write(buffer, 0, buffer.Length);
reqst.Flush();
reqst.Close();
HttpWebResponse res = (HttpWebResponse)req.GetResponse();
Stream resst = res.GetResponseStream();
StreamReader sr = new StreamReader(resst);
string response = sr.ReadToEnd();
It's not so complicated after all.
theDude
|
|
Expert:
|
theDude
|
|
Date:
|
Jul 20, 2006
|
|
Time:
|
23:18
|
|
|
|
Votes: Good (0) | Bad (0) Login to rate this answer
|
|
|
Hey man, now I see what you wanted. Sorry that my answer wasn't helpful.
I don't know if you want to share this with us, but what actually is the requirement behind this? Just out of interest!
Cheers
Peter
|
|
Expert:
|
PeterNZ
|
|
Date:
|
Jul 20, 2006
|
|
Time:
|
23:48
|
|
|
|
Votes: Good (0) | Bad (0) Login to rate this answer
|
|
|
It was the implementation of a payment gateway.
It's called nochex (nochex.co.uk) and similar to Paypal it requires that you verify "callbacks" by returning the parameters from a transaction to them and they then respond with an authorization.
|
|
Expert:
|
theDude
|
|
Date:
|
Jul 20, 2006
|
|
Time:
|
23:58
|
|
|
|
Votes: Good (0) | Bad (0) Login to rate this answer
|
|
|
Any way of using this code in a windows application and getting the result to display in a browser?
|
|
Expert:
|
acollings
|
|
Date:
|
Sep 17, 2007
|
|
Time:
|
19:12
|
|
|
|
Votes: Good (0) | Bad (0) Login to rate this answer
|
|
|
|
|
|
|
This question has been answered, and points have been rewarded to the following experts:
You're welcome however to comment or give additional information or if you wish, you have the ability to write an Answer Summary for this question by clicking on the "Answer Summaries" Tab.
|
|