C# 通过ASP.net发送HTTP Post请求

C# 通过ASP.net发送HTTP Post请求,c#,asp.net,forms,http-post,C#,Asp.net,Forms,Http Post,我遇到了一个路障,由于这个问题,在我的项目,任何类型的帮助将高度感谢 我的问题是,我希望用户在我的网站上输入(他们的)目的地和电子邮件。然后,我将获取这些值并填写以下网站上的文本字段,然后单击“请求测量按钮”。简而言之,这是一个简单的HTTP Post请求 我的C#代码如下: // variables to store parameter values string url = "http://revtr.cs.washington.edu/"; // creates

我遇到了一个路障,由于这个问题,在我的项目,任何类型的帮助将高度感谢

我的问题是,我希望用户在我的网站上输入(他们的)目的地和电子邮件。然后,我将获取这些值并填写以下网站上的文本字段,然后单击“请求测量按钮”。简而言之,这是一个简单的HTTP Post请求

我的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的调试器获得此信息)

似乎url必须是

string url = "http://revtr.cs.washington.edu/measure.php";
因为是形式的行动