C# HTTP请求 网页POST提交

用C#窗体程序模拟提交HTTP请求,被提交的网页上的一段代码

 <input type="text" id="web_input" class="inputon" >
 <a href="javascript:;" id="web_button"><img src="guestbook.gif" width="125" height="32" alt=""></a>

其中web_input是文本框,输入文字,下面那个链接web_button是提交按钮,点击链接之后就会提交。我看网上的例子都需要写一个提交参数,例如:pastData=“username=aaa&userpwd=bbb”; 那么我的这个怎么写呢?主要是不知道那个连接那一块,麻烦大神给出那个提交参数?

需要写后台方法
http://www.cnblogs.com/cgli/archive/2011/04/09/2010497.html

 <form name="input" action="test.php" method="post">
    <input type="text" id="web_input" name="web_input" class="inputon" >
    <a href="javascript:;" id="web_button"><img src="guestbook.gif" width="125" height="32" alt=""></a>
</form>

在test.php文件中用$_POST["web_input"] 就能得到提交的东西。

我也是新手,不知道对不对。

你要用开发工具找到提交页面的接口,然后用WebRequest直接post数据到接口去就好了,注意人家网站的编码

 string postdata = "sort=xxxxx&type=xxxxxx";
byte[] bytes = Encoding.ASCII.GetBytes(postData);//注意i编码
Stream sendStream = request.GetRequestStream();
sendStream.Write(bytes, 0, bytes.Length);
sendStream.Close();
HttpWebResponse response = (HttpWebResponse)request.GetResponse()

楼主使用C#的话,我就当你使用的是WebForm了,

/asp:TextBox
/asp:ImageButton

楼主使用C#的话,我就当你使用的是WebForm了,

 <asp:TextBox runat="server" ID="web_input" CssClass="inputon" ></asp:TextBox>
<asp:ImageButton runat="server" ID="web_button" ImageUrl="guestbook.gif" Height="125" Width="32" OnClick="自己在Code页面新建一个ImageButton的点击事件" ></asp:ImageButton>

如果用get提交,你点一下网页的那个提交按钮,看浏览器上的地址栏,你就懂了。

如果用post提交,你用任何一个能看HTTP的header的,看下post的内容就可以了。

然后你就会写了。

pastData=“username=aaa&userpwd=bbb”
具体提交什么和你的提交url需要的参数有关系