I want ot submit a form residing on other domain from my asp.net application.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • asad1605
    New Member
    • Aug 2010
    • 1

    I want ot submit a form residing on other domain from my asp.net application.

    [I want to submit a form residing on other domain from my asp.net application.] 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:
    Code:
    string url = "http://www.concorindia.com/containerquery.aspx";         
        
    WebRequest request = WebRequest.Create(url);
        
    request.Method = "POST";
    
    string postData = "contno=123456&CONTButton1='Submit Query'";
         
    byte[] byteArray = Encoding.UTF8.GetBytes(postData);
    request.ContentType = "application/x-www-form-urlencoded";
    request.ContentLength = byteArray.Length;
    Stream dataStream = request.GetRequestStream();
    dataStream.Write(byteArray, 0, byteArray.Length);
    dataStream.Close();
        
    WebResponse response = request.GetResponse();
    dataStream = response.GetResponseStream();
    StreamReader reader = new StreamReader(dataStream);
    string responseFromServer = reader.ReadToEnd();
    response.Wtrite(responseFromServer);
    Last edited by Frinavale; Aug 19 '10, 01:05 PM. Reason: Please post code in [code] ... [/code] tags. Added code tags. Added the first sentence.
Working...