C# 如何以编程方式调用示例网页上的按钮
我在网页上也做过类似的尝试。我的意思是,在web页面上,我单击按钮,post事件从asp页面请求我的查询结果 在这里,我以编程的方式尝试它C# 如何以编程方式调用示例网页上的按钮,c#,.net,httpwebrequest,http-post,C#,.net,Httpwebrequest,Http Post,我在网页上也做过类似的尝试。我的意思是,在web页面上,我单击按钮,post事件从asp页面请求我的查询结果 在这里,我以编程的方式尝试它 string paramaters = "sql=select+%2A+from+hsp%5Fistanbul+u+where+u%2Ehsp%5Fhosdere%5Fno+%3D+28960099"; string strResponse; HttpWebRequest requestLogin = (HttpWebRequest)WebRequ
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();
考虑使用?参数是不合适的,这就是为什么我使用firebug查看post数据。然后它就开始工作了