1

私のプロジェクトでこの問題が原因で障害が発生しました。どんな種類の助けも大歓迎です。

私の問題は、ユーザーが自分の Web サイトで宛先と電子メールを入力することです。次に、これらの値を取得して、次の Web サイトのテキスト フィールドに入力し、[測定のリクエスト] ボタンをクリックします。簡単に言えば、単純な 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は、プログラムの実行時に BUTTON がクリックされていないことを示しています (VS2010 のデバッガーからこの情報を取得しました)。

4

1 に答える 1

2

URLは次のようになります

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

フォームのアクションです。

于 2012-05-29T11:16:46.737 に答える