I want to submit a form residing on other domain from my asp.net appliocation and then get result in my asp.net page(response). I have tried the way in which HTTPWebRequest and HTTPWebResponse objects were used, but no success.
For more clarity, i want to send a container no. to a website providing container tracking and get the result page html in my control.
There is no authentication there. Webite url is "http://www.concorindia.com/containerquery.aspx". Is there any other way to accomplish this?
I am using the code:
1. string url = "http://www.concorindia.com/containerquery.aspx";
2.
3. WebRequest request = WebRequest.Create(url);
4.
5. request.Method = "POST";
6.
7. string postData = "contno=123456&CONTButton1='Submit Query'";
8.
9. byte[] byteArray = Encoding.UTF8.GetBytes(postData);
10. request.ContentType = "application/x-www-form-urlencoded";
11. request.ContentLength = byteArray.Length;
12. Stream dataStream = request.GetRequestStream();
13. dataStream.Write(byteArray, 0, byteArray.Length);
14. dataStream.Close();
15.
16. WebResponse response = request.GetResponse();
17. dataStream = response.GetResponseStream();
18. StreamReader reader = new StreamReader(dataStream);
19. string responseFromServer = reader.ReadToEnd();
20. response.Wtrite(responseFromServer);