Select Categories Below
Status: Closed Points: 75 Time: 09:51 - Jul 19, 2006
theDude
How can i create a post request programmatically in asp.net (C#) without having to actually submit an html-form? Is it possible?
Categories:
Add Categories
When adding more than one category, separate them with commas.
Advertisement
PeterNZ
Date:: Jul 19, 2006
Time:: 21:56
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
Date:: Jul 20, 2006
Time:: 23:18
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
Time:: 23:48
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
Time:: 23:58
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.
acollings
Date:: Sep 17, 2007
Time:: 19:12
Any way of using this code in a windows application and getting the result to display in a browser?
Question Answered
This question has been closed, 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 the Summary Area.
Answer this Question
New User
Email:
Upon submission of this form, you will automatically be registered as a Quomon user and we will send your login information to this address
Registered User
Username:
Password:
Forgot Your Password?
Enter your email address below and we will resend your login information to you.
Login Information Sent
Questions
hover gallery.
How long does Google and MSN store emails that can...
Does the United States Government have a CIO posit...
How do you turn off the signature option in the ad...
audio quality- when playing music/video's, the sou...
Thanks for your reply. Where are you located? Whic...
You have 100 characters to use
Rank
Expert
Points
1.
738
2.
495
3.
450
4.
297
5.
215
6.
75
7.
50
8.
9.
10.
30
Register today to share your knowledge with the community and be recognized and rewarded for your contributions.
Register Here
"Psst, Quomon is a great site. Pass it on." Tell a Friend | Link To Us | Save to Delicious | Digg it
Language Options
English:
Español:
Sponsors
Questions and Answers Software Real Estate Postcards Marketing Fulfillment