2012-05-29 6 views
1

내 프로젝트에서이 문제로 도로 블록을 쳤습니다. 어떤 종류의 도움이라도 대단히 감사하겠습니다.ASP.net을 통한 HTTP 포스트 요청 전송

내 문제는 내 웹 사이트에서 사용자가 자신의 대상인 & 이메일을 입력하도록하려는 것입니다. 그런 다음 해당 값을 가져 와서 다음 웹 사이트의 텍스트 필드에 입력 한 다음 "측정 요청 버튼"을 클릭하십시오. 간단히 말해서 간단한 HTTP POST 요청. 다음과 같이

http://revtr.cs.washington.edu/

내 C# 코드는 다음과 같습니다

// variables to store parameter values 
    string url = "http://revtr.cs.washington.edu/"; 

    // creates the post data for the POST request 
    string postData = ("destination=www.thechive.com&node=161&email=abc%40xyz.edu.pk&prediction=If+you+believe+you+know+the+traceroute+%28for+instance%2C+if+you+are+trying+out+our+system+using+a+destination+that+you+actually+control%29%2C+please+cut-and-paste+the+traceroute+into+this+box+to+aid+us+in+improving+our+system."); 

    // create the POST request 
    HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(url); 
    webRequest.Method = "POST"; 
    webRequest.ContentType = "application/x-www-form-urlencoded"; 
    webRequest.ContentLength = postData.Length; 

    // POST the data 
    using (StreamWriter requestWriter2 = new StreamWriter(webRequest.GetRequestStream())) 
    { 
     requestWriter2.Write(postData); 
    } 

    // This actually does the request and gets the response back 
    HttpWebResponse resp = (HttpWebResponse)webRequest.GetResponse(); 

    string responseData = string.Empty; 

    using (StreamReader responseReader = new StreamReader(webRequest.GetResponse().GetResponseStream())) 
    { 
     // dumps the HTML from the response into a string variable 
     responseData = responseReader.ReadToEnd(); 
    } 

    // Now, find the index of some word on the page that would be 
    //  displayed if the login was successful 
    int index = responseData.IndexOf("Measuring"); 

    if (index > -1) 
     ListBox1.Items.Add("SUCCESS"); 

을하지만 드 responseData 프로그램이 실행될 때 버튼이 클릭되지 않았 음을 보여줍니다 (나는의 디버거에서이 정보를 가지고 VS2010는)

답변

2

이 URL이 있어야합니다 보인다

string url = "http://revtr.cs.washington.edu/measure.php"; 
,536,

이 이후 양식의 동작입니다.

+0

굉장해 고마워 :) – asad