Forum Moderators: open
background:
i have a form that, upon completion, inserts the values into my database. i need to then push these values to another site to be inputted into that db. i was hoping to use HTTPPOST. can anyone point me in the right direction to performing this task? i think i have to use the httpwebrequest class, but i'm not entirely sure. thanks.
-Matt
string postData = "name=ziggy&occ=singer"; [i]// Separate each field in the form with a &[/i]
string useURL = "http://www.ilikethisurl.com/default.aspx";
[i]// Create an instance of the WebRequest class[/i]
WebRequest objRequest = WebRequest.Create(useURL);
objRequest.Timeout = 60000; [i]// In milliseconds - in this case 60 seconds[/i]
objRequest.Method = "POST";
objRequest.ContentLength = postData.Length;
objRequest.ContentType = "application/x-www-form-urlencoded";
[i]// Create an instance of the StreamWriter class and attach the WebRequest object to it - here's where we do the posting[/i]
StreamWriter postWriter = new StreamWriter(objRequest.GetRequestStream());
postWriter.Write(postData);
postWriter.Close();
[i]// Create an instance of the WebResponse class and get the output to the rawOutput string[/i]
WebResponse objResponse = objRequest.GetResponse();
StreamReader sr = new StreamReader(objResponse.GetResponseStream());
string rawOutput= sr.ReadToEnd();
sr.Close();
Also, I recommend you add some exception handling, for what happens when the connection times out, can't find server etc. etc.
Good luck
//ZS
background:
i am collecting data via asp.net form. this data gets submitted to verisign for the customer to enter their payment info. all i need to do is post data TO verisign, NOT postback, which is impossible with .NET. i cannot use the WebRequest class, because i need the user to stay on verisign's site. hopefully that's understandable...
should i be using server.transfer? i need to pass the variables, but i cannot have the data in the querystring.
-Matt