【问题标题】:How can I invoke a button on an example web page programmatically如何以编程方式调用示例网页上的按钮
【发布时间】:2012-05-15 10:11:03
【问题描述】:

我确实尝试过类似网页上的操作。我的意思是,在网页上,我单击按钮,发布事件从 ASP 页面请求我的查询结果。

在这里,我确实以编程方式尝试;

string paramaters = "sql=select+%2A+from+hsp%5Fistanbul+u+where+u%2Ehsp%5Fhosdere%5Fno+%3D+28960099";
    string strResponse;

HttpWebRequest requestLogin = (HttpWebRequest)WebRequest.Create("http://10.1.20.39/query/query.asp");
requestLogin.Credentials = new NetworkCredential("xyz", "tyewrrf"); 
requestLogin.Method = "POST"; 
 requestLogin.ContentType = "application/x-www-form-urlencoded"; 
requestLogin.ContentLength = paramaters.Length; 
StreamWriter stOut = new StreamWriter(requestLogin.GetRequestStream(), System.Text.Encoding.ASCII);
stOut.Write(paramaters); 
stOut.Close();
HttpWebResponse responseLogin = (HttpWebResponse)requestLogin.GetResponse(); 
StreamReader stIn = new StreamReader(responseLogin.GetResponseStream());
strResponse = stIn.ReadToEnd();// here I want to get the the same html codes as if I do click on the web page...
stIn.Close();  

【问题讨论】:

    标签: c# .net httpwebrequest http-post


    【解决方案1】:

    考虑使用http://watin.org/ ?

    【讨论】:

      【解决方案2】:

      参数不好,所以我用firebug来查看post数据。然后它开始工作了。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2021-09-30
        • 1970-01-01
        • 2012-05-11
        • 2014-05-21
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多