Alex Rivera | Logout

How do I POST data to a remote URL in Classic ASP?

Asked 2008-12-19T17:20:54.153
23

I need to POST data to a url in the middle of a script.

  1. User fills out form:
  2. Form submits to process.asp: I need to POST data to a 3rd Party integration at this point.
  3. process.asp finishes and directs user to thank you page.
Edit
Report

3 Answers

2

If you're stuck with class ASP, you can do it with the commercial ASPHTTP library here:

http://www.serverobjects.com/comp/asphttp3.htm

answered 2008-12-19T17:28:32.793
1

OK all the answers were very complicated and I know you already selected a solution - but I feel like the simple Server.Transfer() command could have done exactly what you need.

At the end of your script instead of Response.Redirect(url) to the new page - just do a Server.Transfer(url) and it will pass your entire Request collection across to the next page.

Read about it here (support.microsoft.com).

There are some catches (i.e. it keeps the same URL on the browser so it can play tricks with the back button and such) but otherwise it's pretty simple.

answered 2011-04-19T03:37:01.323
-1

You can do it by many way. With WebClient

 WebClient Client = new WebClient ();
 Client.DownloadFile("http://www.stackoverflow.com/myfile.html", "myfile.html");

Or you can put the data in a stream to use it in your program:

WebClient Client = new WebClient ();
Stream strm = Client.OpenRead ("http://www.stackoverflow.com/myfile.htm");

But I do prefer use HttpWebRequest:

HttpWebRequest objRequest = (HttpWebRequest)WebRequest.Create("http://www.stackoverflow.com/myfile.html");
StreamWriter myWriter = new StreamWriter(objRequest.GetRequestStream());

I prefer the second one because you can have more option for POST/GET or for Cookie.

answered 2008-12-19T17:34:44.483

Your Answer