Answers
Jul 19, 2006 - 06:56 PM
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
Jul 20, 2006 - 08:18 PM
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
Jul 20, 2006 - 08:48 PM
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
Jul 20, 2006 - 08:58 PM
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.
Sep 17, 2007 - 04:12 PM
Add New Comment