Consuming POST data and repostit back

xwarlordx

New Member
I'm trying to consume a data sent throw a \[code\]WebRequest.Methode = "POST"\[/code\] in another page and send the same data back to the page that requested it. this is my link that I'm trying to acces: localhost:59325/api/test.aspx?supplier_send_url=http://localhost:59325/api/test2.aspx .In my test.aspx I have this:\[code\]protected void Page_Load(object sender, EventArgs e) { string urlDestination = Request.QueryString[0]; string mesaj = "Test"; byte[] buffer = Encoding.ASCII.GetBytes(mesaj); HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(urlDestination); webRequest.Method = "POST"; webRequest.ContentType = "application/x-www-form-urlencoded"; webRequest.ContentLength = buffer.Length; Stream writer = webRequest.GetRequestStream(); writer.Write(buffer, 0, buffer.Length); writer.Close(); string response = new StreamReader(webRequest.GetResponse().GetResponseStream()).ReadToEnd(); if (((HttpWebResponse)webRequest.GetResponse()).StatusCode.Equals(HttpStatusCode.OK)) { Response.Write(response + "OK"); } else { Response.Write("Error!"); } }\[/code\]I succesfully sended the "Test" message and successfully read the message but now I have to send it back to the request and don't know who to do it. This is my send_direct_soap:\[code\]public override void process(NameValueCollection parametersReceived) { string urlDestination = parametersReceived[Includes.SUPPLIER_URL]; StringBuilder requestData = http://stackoverflow.com/questions/13875937/new StringBuilder(); HttpWebRequest webRequest = null; foreach (String parameter in parametersReceived.Keys) { if (requestData.Length > 0) requestData.Append("&"); requestData.Append(parameter + "=" + parametersReceived[parameter]); } saveMyLog("DATA COMMUNICATION: \n Destination: " + urlDestination + "\n Request: " + requestData); webRequest = (HttpWebRequest)WebRequest.Create(new Uri(urlDestination)); webRequest.Method = "POST"; webRequest.ContentType = "text/xml"; webRequest.Headers.Add("SOAPAction", urlDestination); using (StreamWriter requestStream = new StreamWriter(webRequest.GetRequestStream())) { requestStream.Write(requestData); } saveMyLog("\n Status: " + ((HttpWebResponse)req.GetResponse()).StatusCode.ToString() + "\n Response: " + Response); }\[/code\]The parametersRecived ar the Request.Form keys.I need to send the message back so that I can Resone.Write it in the browser page. I don't know how to send it back. Thanks.
 
Back
Top